In [1]:
from owslib.wps import WebProcessingService, monitorExecution, printInputOutput
from os import system
import time
from owslib.etree import etree
In [ ]:
In [2]:
wps_url = "http://localhost:8080/geoserver/wps"
# wps_url= "http://earss1.ornl.gov:80/geoserver/wps"
# wps_url = "http://localhost:8093/wps"
# wps_url = "https://publicwiki.deltares.nl/display/OET/WPS"
wps = WebProcessingService(url=wps_url, verbose=False)
In [3]:
print (wps.identification.title + ':' + wps.version)
In [4]:
# for process in wps.processes:
# print ('%s : \t %s' % (process.identifier, process.abstract))
In [41]:
p = wps.describeprocess(identifier='JTS:length')
print("Inputs")
for input in p.dataInputs:
printInputOutput(input)
print ('\n')
print("Outputs")
for output in p.processOutputs:
printInputOutput(output)
print ('\n')
In [33]:
def wrapXML(proces,geom):
xml='<?xml version="1.0" encoding="UTF-8"?><wps:Execute version="1.0.0" service="WPS" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.opengis.net/wps/1.0.0" xmlns:wfs="http://www.opengis.net/wfs" xmlns:wps="http://www.opengis.net/wps/1.0.0" xmlns:ows="http://www.opengis.net/ows/1.1" xmlns:gml="http://www.opengis.net/gml" xmlns:ogc="http://www.opengis.net/ogc" xmlns:wcs="http://www.opengis.net/wcs/1.1.1" xmlns:xlink="http://www.w3.org/1999/xlink" xsi:schemaLocation="http://www.opengis.net/wps/1.0.0 http://schemas.opengis.net/wps/1.0.0/wpsAll.xsd"> <ows:Identifier>%s</ows:Identifier><wps:DataInputs><wps:Input><ows:Identifier>geom</ows:Identifier><wps:Data><wps:ComplexData mimeType="application/json"><![CDATA[%s]]></wps:ComplexData></wps:Data></wps:Input></wps:DataInputs><wps:ResponseForm><wps:RawDataOutput><ows:Identifier>result</ows:Identifier></wps:RawDataOutput></wps:ResponseForm></wps:Execute>'%(proces,geom)
return xml.strip()
In [43]:
from osgeo import ogr
import requests
poly = ogr.Geometry(ogr.wkbLinearRing)
polygon = [(-102.8184, 39.5273), (-102.8184, 37.418), (-101.2363, 37.418), (-101.2363, 39.5273), (-102.8184, 39.5273)]
for i in polygon:
poly.AddPoint(*i)
p=poly.ExportToJson()
dowyslania=wrapXML("JTS:length",p)
# ExportToWkt()
r = requests.post("http://185.52.194.216:8080/geoserver/wps?JTS:numGeometries", data=dowyslania)
print(r.status_code, r.reason)
print(r.text[:])
In [38]:
from owslib.wps import GMLMultiPolygonFeatureCollection
from owslib.wps import WebProcessingService, monitorExecution, printInputOutput
from os import system
import time
from owslib.etree import etree
wps_url = "http://localhost:8080/geoserver/wps"
wps = WebProcessingService(url=wps_url, verbose=False)
polygon = [(-102.8184, 39.5273), (-102.8184, 37.418), (-101.2363, 37.418), (-101.2363, 39.5273), (-102.8184, 39.5273)]
featureCollection = GMLMultiPolygonFeatureCollection( [polygon] )
print( featureCollection.getXml())
inputs1 = [ ("geom",featureCollection)]
# execute = wps.execute(identifier='JTS:numGeometries', inputs=inputs1)
In [ ]: