4

I am writing a geoprocessing script that will need to accept a shape as an input parameter. This shape will be obtained by a user drawing the shape in a web application. The web application will execute the geoprocessing service, providing the coordinate string of the shape as an input parameter.

In the geoprocessing script tool's definition, I would assume that this input parameter would be of type FeatureSet and that within the script you would use arcpy.GetParameter to access this input parameter. Where I know that the input parameter will always be exactly one feature (string of coordinates), is there a better alternative than using a FeatureSet as the input parameter type?

3 Answers 3

4

If your users will be "digitizing" shapes, then you'll want to use the FeatureSet parameter. This parameter is meant to take simple input features (usually drawn as you've described).

inFS = arcpy.GetParameterAsText(0)

arcpy.Buffer_analysis(inFS, "output", "100 Miles")
3

I implemented something very similar. A client app had the user choose a few points and then I sent this over to ArcGIS Server GP Service as a string with C#. I then had the python script convert the string to a feature class/shapefile in the GP jobs directory and went from there with a bomb app! The answer from polygeo is the route I probably should have taken but I was under a deadline and couldn't afford the time to figure that piece out. The answer from KHibma sounds very promising as gp tools (I imagine gp services as well) take a very cool parameter called a feature set which allows you to draw into memory (when in ArcMap) a feature but you have to have a schema (a shapefile/feature class with witch to define all the regular stuff when creating a new shapefile/feature class) already defined which should not preclude you much. I'd be very happy to help out in any way with this as I am not working on this type of stuff at the moment and would like to recollect those adventures!

1
  • With 10.1 you can define the schema of the featureset you're passing in. But I'd figure if you've created an application to allow users to draw features, then you probably already have a set schema (but theres always exceptions to the rules...) but yeah, in my answer I guess I just assumed features would be passed in (not some sort of string of coordinates). Either way would work, but I think passing features in is easier as the framework handles it for you. (opposed to parsing a string into features via the script)
    – KHibma
    Jan 8, 2013 at 21:35
2

I think you will need to use JSON/GeoJSON.

For ideas on how to include long JSON objects (e.g. a polygon geometry as a coordinate string) into a POST request to a Geoprocessing Service, and then how to read it as a parameter in a Python script published as a Geoprocessing Service please see How to send long JSON objects (polygon geometry, table rows) in POST request to Geoprocessing Service?.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.