| 1 |
Inspect a remote WPS and retrieve the supported processes: |
| 2 |
|
| 3 |
>>> from owslib.wps import WebProcessingService |
| 4 |
>>> wps = WebProcessingService('http://cida.usgs.gov/climate/gdp/process/WebProcessingService', skip_caps=True) |
| 5 |
>>> wps.getcapabilities() |
| 6 |
>>> wps.identification.type |
| 7 |
'WPS' |
| 8 |
>>> wps.identification.title |
| 9 |
'Geo Data Portal WPS Processing' |
| 10 |
>>> wps.identification.abstract |
| 11 |
'Geo Data Portal WPS Processing' |
| 12 |
>>> for operation in wps.operations: |
| 13 |
... operation.name |
| 14 |
... |
| 15 |
'GetCapabilities' |
| 16 |
'DescribeProcess' |
| 17 |
'Execute' |
| 18 |
>>> for process in wps.processes: |
| 19 |
... process.identifier, process.title |
| 20 |
... |
| 21 |
('gov.usgs.cida.gdp.wps.algorithm.FeatureCoverageIntersectionAlgorithm', 'Feature Coverage WCS Intersection') |
| 22 |
('gov.usgs.cida.gdp.wps.algorithm.FeatureCoverageOPeNDAPIntersectionAlgorithm', 'Feature Coverage OPeNDAP Intersection') |
| 23 |
('gov.usgs.cida.gdp.wps.algorithm.FeatureCategoricalGridCoverageAlgorithm', 'Feature Categorical Grid Coverage') |
| 24 |
('gov.usgs.cida.gdp.wps.algorithm.FeatureWeightedGridStatisticsAlgorithm', 'Feature Weighted Grid Statistics') |
| 25 |
('gov.usgs.cida.gdp.wps.algorithm.FeatureGridStatisticsAlgorithm', 'Feature Grid Statistics') |
| 26 |
('gov.usgs.cida.gdp.wps.algorithm.PRMSParameterGeneratorAlgorithm', 'PRMS Parameter Generator') |
| 27 |
>>> |
| 28 |
|
| 29 |
|
| 30 |
Determine how a specific process needs to be invoked - i.e. what are its input parameters, and output result: |
| 31 |
|
| 32 |
>>> from owslib.wps import printInputOutput |
| 33 |
>>> process = wps.describeprocess('gov.usgs.cida.gdp.wps.algorithm.FeatureWeightedGridStatisticsAlgorithm') |
| 34 |
>>> process.identifier |
| 35 |
'gov.usgs.cida.gdp.wps.algorithm.FeatureWeightedGridStatisticsAlgorithm' |
| 36 |
>>> process.title |
| 37 |
'Feature Weighted Grid Statistics' |
| 38 |
>>> process.abstract |
| 39 |
'This algorithm generates area weighted statistics of a gridded dataset for a set of vector polygon features. Using the bounding-box that encloses ... |
| 40 |
>>> for input in process.dataInputs: |
| 41 |
... printInputOutput(input) |
| 42 |
... |
| 43 |
identifier=FEATURE_COLLECTION, title=Feature Collection, abstract=A feature collection encoded as a WFS request or one of the supported GML profiles.,... |
| 44 |
Supported Value: mimeType=text/xml, encoding=UTF-8, schema=http://schemas.opengis.net/gml/2.0.0/feature.xsd |
| 45 |
Supported Value: mimeType=text/xml, encoding=UTF-8, schema=http://schemas.opengis.net/gml/2.1.1/feature.xsd |
| 46 |
Supported Value: mimeType=text/xml, encoding=UTF-8, schema=http://schemas.opengis.net/gml/2.1.2/feature.xsd |
| 47 |
Supported Value: mimeType=text/xml, encoding=UTF-8, schema=http://schemas.opengis.net/gml/2.1.2.1/feature.xsd |
| 48 |
Supported Value: mimeType=text/xml, encoding=UTF-8, schema=http://schemas.opengis.net/gml/3.0.0/base/feature.xsd |
| 49 |
Supported Value: mimeType=text/xml, encoding=UTF-8, schema=http://schemas.opengis.net/gml/3.0.1/base/feature.xsd |
| 50 |
Supported Value: mimeType=text/xml, encoding=UTF-8, schema=http://schemas.opengis.net/gml/3.1.0/base/feature.xsd |
| 51 |
Supported Value: mimeType=text/xml, encoding=UTF-8, schema=http://schemas.opengis.net/gml/3.1.1/base/feature.xsd |
| 52 |
Supported Value: mimeType=text/xml, encoding=UTF-8, schema=http://schemas.opengis.net/gml/3.2.1/base/feature.xsd |
| 53 |
Default Value: mimeType=text/xml, encoding=UTF-8, schema=http://schemas.opengis.net/gml/2.0.0/feature.xsd |
| 54 |
minOccurs=1, maxOccurs=1 |
| 55 |
identifier=DATASET_URI, title=Dataset URI, abstract=The base data web service URI for the dataset of interest., data type=anyURI |
| 56 |
Allowed Value: AnyValue |
| 57 |
Default Value: None |
| 58 |
minOccurs=1, maxOccurs=1 |
| 59 |
identifier=DATASET_ID, title=Dataset Identifier, abstract=The unique identifier for the data type or variable of interest., data type=string |
| 60 |
Allowed Value: AnyValue |
| 61 |
Default Value: None |
| 62 |
minOccurs=1, maxOccurs=2147483647 |
| 63 |
identifier=REQUIRE_FULL_COVERAGE, title=Require Full Coverage, abstract=If turned on, the service will require that the dataset of interest .... |
| 64 |
Allowed Value: True |
| 65 |
Default Value: True |
| 66 |
minOccurs=1, maxOccurs=1 |
| 67 |
identifier=TIME_START, title=Time Start, abstract=The date to begin analysis., data type=dateTime |
| 68 |
Allowed Value: AnyValue |
| 69 |
Default Value: None |
| 70 |
minOccurs=0, maxOccurs=1 |
| 71 |
identifier=TIME_END, title=Time End, abstract=The date to end analysis., data type=dateTime |
| 72 |
Allowed Value: AnyValue |
| 73 |
Default Value: None |
| 74 |
minOccurs=0, maxOccurs=1 |
| 75 |
identifier=FEATURE_ATTRIBUTE_NAME, title=Feature Attribute Name, abstract=The attribute that will be used to label column headers in processing output., ... |
| 76 |
Allowed Value: AnyValue |
| 77 |
Default Value: None |
| 78 |
minOccurs=1, maxOccurs=1 |
| 79 |
identifier=DELIMITER, title=Delimiter, abstract=The delimiter that will be used to separate columns in the processing output., data type=string |
| 80 |
Allowed Value: COMMA |
| 81 |
Allowed Value: TAB |
| 82 |
Allowed Value: SPACE |
| 83 |
Default Value: COMMA |
| 84 |
minOccurs=1, maxOccurs=1 |
| 85 |
identifier=STATISTICS, title=Statistics, abstract=Statistics that will be returned for each feature in the processing output., data type=string |
| 86 |
Allowed Value: MEAN |
| 87 |
Allowed Value: MINIMUM |
| 88 |
Allowed Value: MAXIMUM |
| 89 |
Allowed Value: VARIANCE |
| 90 |
Allowed Value: STD_DEV |
| 91 |
Allowed Value: SUM |
| 92 |
Allowed Value: COUNT |
| 93 |
Default Value: None |
| 94 |
minOccurs=1, maxOccurs=7 |
| 95 |
identifier=GROUP_BY, title=Group By, abstract=If multiple features and statistics are selected, this will change whether the processing output ... |
| 96 |
Allowed Value: STATISTIC |
| 97 |
Allowed Value: FEATURE_ATTRIBUTE |
| 98 |
Default Value: None |
| 99 |
minOccurs=1, maxOccurs=1 |
| 100 |
identifier=SUMMARIZE_TIMESTEP, title=Summarize Timestep, abstract=If selected, processing output will include columns with summarized statistics ... |
| 101 |
Allowed Value: True |
| 102 |
Default Value: True |
| 103 |
minOccurs=0, maxOccurs=1 |
| 104 |
identifier=SUMMARIZE_FEATURE_ATTRIBUTE, title=Summarize Feature Attribute, abstract=If selected, processing output will include a final row of ... |
| 105 |
Allowed Value: True |
| 106 |
Default Value: True |
| 107 |
minOccurs=0, maxOccurs=1 |
| 108 |
>>> for output in process.processOutputs: |
| 109 |
... printInputOutput(output) |
| 110 |
... |
| 111 |
identifier=OUTPUT, title=Output File, abstract=A delimited text file containing requested process output., data type=ComplexData |
| 112 |
Supported Value: mimeType=text/csv, encoding=UTF-8, schema=None |
| 113 |
Default Value: mimeType=text/csv, encoding=UTF-8, schema=None |
| 114 |
reference=None, mimeType=None |
| 115 |
>>> |
| 116 |
|
| 117 |
Submit a processing request (extraction of a climate index variable over a specific GML polygon, for a given period of time), monitor the execution until complete: |
| 118 |
|
| 119 |
>>> from owslib.wps import GMLMultiPolygonFeatureCollection |
| 120 |
>>> polygon = [(-102.8184, 39.5273), (-102.8184, 37.418), (-101.2363, 37.418), (-101.2363, 39.5273), (-102.8184, 39.5273)] |
| 121 |
>>> featureCollection = GMLMultiPolygonFeatureCollection( [polygon] ) |
| 122 |
>>> processid = 'gov.usgs.cida.gdp.wps.algorithm.FeatureWeightedGridStatisticsAlgorithm' |
| 123 |
>>> inputs = [ ("FEATURE_ATTRIBUTE_NAME","the_geom"), |
| 124 |
... ("DATASET_URI", "dods://cida.usgs.gov/qa/thredds/dodsC/derivatives/derivative-days_above_threshold.pr.ncml"), |
| 125 |
... ("DATASET_ID", "ensemble_b1_pr-days_above_threshold"), |
| 126 |
... ("TIME_START","2010-01-01T00:00:00.000Z"), |
| 127 |
... ("TIME_END","2011-01-01T00:00:00.000Z"), |
| 128 |
... ("REQUIRE_FULL_COVERAGE","false"), |
| 129 |
... ("DELIMITER","COMMA"), |
| 130 |
... ("STATISTICS","MEAN"), |
| 131 |
... ("GROUP_BY","STATISTIC"), |
| 132 |
... ("SUMMARIZE_TIMESTEP","false"), |
| 133 |
... ("SUMMARIZE_FEATURE_ATTRIBUTE","false"), |
| 134 |
... ("FEATURE_COLLECTION", featureCollection) |
| 135 |
... ] |
| 136 |
>>> output = "OUTPUT" |
| 137 |
>>> execution = wps.execute(processid, inputs, output = "OUTPUT") |
| 138 |
Executing WPS request... |
| 139 |
Execution status=ProcessStarted |
| 140 |
>>> from owslib.wps import monitorExecution |
| 141 |
>>> monitorExecution(execution) |
| 142 |
Checking execution status... (location=http://cida.usgs.gov/climate/gdp/process/RetrieveResultServlet?id=6809217153012787208) |
| 143 |
Execution status=ProcessSucceeded |
| 144 |
Execution status: ProcessSucceeded |
| 145 |
Output URL=http://cida.usgs.gov/climate/gdp/process/RetrieveResultServlet?id=6809217153012787208OUTPUT.3cbcd666-a912-456f-84a3-6ede450aca95 |
| 146 |
|
| 147 |
Alternatively, define the feature through an embedded query to a WFS server: |
| 148 |
|
| 149 |
>>> from owslib.wps import WFSQuery, WFSFeatureCollection |
| 150 |
>>> wfsUrl = "http://cida.usgs.gov/climate/gdp/proxy/http://igsarm-cida-gdp2.er.usgs.gov:8082/geoserver/wfs" |
| 151 |
>>> query = WFSQuery("sample:CONUS_States", propertyNames=['the_geom',"STATE"], filters=["CONUS_States.508","CONUS_States.469"]) |
| 152 |
>>> featureCollection = WFSFeatureCollection(wfsUrl, query) |
| 153 |
>>> # same process submission as above |
| 154 |
... |
| 155 |
|
| 156 |
You can also submit a pre-made request encoded as WPS XML: |
| 157 |
|
| 158 |
>>> request = open('/Users/cinquini/Documents/workspace-cog/wps/tests/resources/wps_USGSExecuteRequest1.xml','rb').read() |
| 159 |
>>> execution = wps.execute(None, [], request=request) |
| 160 |
Executing WPS request... |
| 161 |
Execution status=ProcessStarted |
| 162 |
>>> monitorExecution(execution) |
| 163 |
Checking execution status... (location=http://cida.usgs.gov/climate/gdp/process/RetrieveResultServlet?id=5103866488472745994) |
| 164 |
Execution status=ProcessSucceeded |
| 165 |
Execution status: ProcessSucceeded |
| 166 |
Output URL=http://cida.usgs.gov/climate/gdp/process/RetrieveResultServlet?id=5103866488472745994OUTPUT.f80e2a78-96a9-4343-9777-be60fac5b256 |