Dear list,
I need your help with a more advanced wps python script with Geoscript. Thank you all in advance for your valuable time and comments.
I have successfully installed the 2.5.1 Geoserver with the geoscript and wps extensions and implemented some simple examples as the one described here:
http://suite.opengeo.org/opengeo-docs/processing/scripting/processcreate.html
I have also successfully implemented my own wps that combines gs:BarnesSurface and gs:Contour
For your help gs:Contour is defined here:
As you can see it requires as input either levels that is type double either interval that is type Double
The following code is working fine having “interval” in place of “levels” and “Double” instead of “ArrayList()” but I can’t find how I should define levels1 in order to make it work with Double.
I have made some efforts as the following code that is throwing an error
org.geotools.process.ProcessException: Could not convert -100 to target type [D
Do you have any ideas how to define levels1 in order to make it work?
Kind Regars,
Vassilis Dalakas
from java.lang import String, Integer, Double
from geoscript.layer import Layer, Raster
from geoserver.wps import process
from geoscript.process import Process
from geoscript.geom import *
from org.geotools.data.simple import SimpleFeatureCollection
from org.geotools.geometry.jts import ReferencedEnvelope
from org.geotools.coverage.grid import GridCoverage2D
from java.util import ArrayList as ArrayList
barnes = Process.lookup(‘gs:BarnesSurface’)
contour = Process.lookup(‘gs:Contour’)
@process(
title = ‘Barnes and Contour’,
description = ‘Uses Barnes Analysis to compute an interpolated surface over a set of irregular data points and computes contour lines at specified intervals or levels for the values in a raster.’,
inputs = {
‘data1’: (SimpleFeatureCollection, ‘Input features’),
‘valueAttr1’: (String, ‘Name of attribute containing the data value to be interpolated’),
‘scale1’: (Double, ‘Length scale for the interpolation, in units of the source data CRS’),
‘maxObservationDistance1’: (Double, ‘Maximum distance to an observation for it to support a grid cell, in units of the source CRS (default = 0, meaning all observations used)’),
‘pixelsPerCell1’: (Integer, ‘Resolution of the computed grid in pixels per grid cell (default = 1)’),
‘queryBuffer1’: (Double, ‘Distance to expand the query envelope by, in units of the source CRS (larger values provide a more stable surface)’),
‘outputBBOX1’: (ReferencedEnvelope, ‘Bounding box for output’),
‘outputWidth1’: (Integer, ‘Width of the output raster in pixels’),
‘outputHeight1’: (Integer, ‘Height of the output raster in pixels’),
‘levels1’: (ArrayList(), ‘Values of levels at which to generate contours’)
},
outputs = {
‘result’: (SimpleFeatureCollection, ‘Contour line features. Contour level is in value attribute.’)
}
)
def run(data1, valueAttr1, scale1, maxObservationDistance1, pixelsPerCell1, queryBuffer1, outputBBOX1, outputWidth1, outputHeight1, levels1):
barnesed = barnes.run(data=data1, valueAttr=valueAttr1, scale=scale1, maxObservationDistance=maxObservationDistance1, pixelsPerCell=pixelsPerCell1, queryBuffer=queryBuffer1, outputBBOX=outputBBOX1, outputWidth=outputWidth1, outputHeight=outputHeight1)[‘result’]
return contour.run(data=barnesed, levels=levels1)[‘result’]