I need to create a Web Processing service on GeoServer (2.11.2) that triggers a 
back-end Python script. This script should be able to utilize requests and 
other packages necessary to do the job.

I have got the wps extension and all necessary GeoScript plugins installed with 
GeoServer.

I followed an example as below to create a custom script that can be called 
from the Admin Web Console WPS Request Builder.

http://suite.opengeo.org/opengeo-docs/processing/scripting/processcreate.html
import math, sys
from geoserver.wps import process
from geoscript.geom import Point
from geoscript.feature import Feature
from geoscript.layer import Layer

@process(
  title = 'Distance and Bearing',
  description = 'Computes Cartesian distance and bearing from features to an 
origin.' + str(sys.executable),
  inputs = {
    'origin': (Point, 'Origin from which to calculate distance and bearing.'), 
    'features': (Layer, 'Features to which distance and bearing should be 
calculated.')
  },
  outputs = {
    'result': (Layer, 'Features with calculated distance and bearing 
attributes.')
  }
)
def run(origin, features):

  for f in features.features():
    p = f.geom.centroid
    d = p.distance(origin)
    b = 90 - math.degrees(math.atan2(p.y - origin.y, p.x - origin.x))

    yield Feature({'point': p, 'distance': d, 'bearing': b})
I tried to use Python's sys library and print out sys.executable as a testing 
process, but the output was NoneType.

I also tried to import requests but the GeoServer logs showed requests cannot 
be found.

I am wondering whether arbitrary Python packages e.g. Requests can be used in a 
script as such supported by GeoServer WPS. Are there any limitations for Python 
scripts that can be triggered as Web Processing Service by GeoServer?
Thanks!
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Geoserver-users mailing list

Please make sure you read the following two resources before posting to this 
list:
- Earning your support instead of buying it, but Ian Turton: 
http://www.ianturton.com/talks/foss4g.html#/
- The GeoServer user list posting guidelines: 
http://geoserver.org/comm/userlist-guidelines.html

Geoserver-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users

Reply via email to