5

I'd like to create a geoprocessing service in ArcGIS Server (10.2) which uses an existing map service as input. I have been trying to do this with a ModelBuilder model, but it's copying the existing map service data to my GP service.

More precisely, what I am doing is using a NRCS soil map unit layer and intersecting with a farm field boundary layer. Both the soil layer and the farm field layer get published with another process.

None of the ESRI examples of GP services show using existing map services as inputs, unless I am missing something.

PolyGeo
65.5k29 gold badges115 silver badges350 bronze badges
asked Dec 12, 2014 at 19:41
5
  • 1
    How are you running this on Desktop (to get a result that you could publish to Server)? GP tools don't work against MapServices. They'll work against FeatureServices, but not map. Commented Dec 12, 2014 at 19:58
  • I do have a FeatureService running for the layers. But I don't see how to use these as input in a ModelBuilder, all I can do is add the database connection from SDE. Doing that, all the data gets copied to the server when I publish. Yes, the SDE geodatabase is registered. Commented Dec 14, 2014 at 14:21
  • If using a FS, give this a read: blogs.esri.com/esri/arcgis/2013/10/10/… you cant directly use a FS as input. You can only use a layer which references a FS. Commented Dec 15, 2014 at 14:38
  • Thanks, Kevin. This is the missing detail I was looking for. I'll post back how it goes after I do the Python script. Commented Dec 16, 2014 at 15:12
  • I have a python script which does a select by attributes working for one layer, which is the field boundary (for a farm). Now I need to intersect this with a larger layer, soil map units. If I can get the extent of the 1st layer, I can get just the soil map unit polygons needed (there's 1000s even in my test on one county). What's the python method for an extent on a layer? Eventually I will figure it out, but thought I'd ask here :-) Commented Dec 16, 2014 at 21:48

1 Answer 1

2

The answer for me was to look at http://blogs.esri.com/esri/arcgis/2013/10/10/quick-tips-consuming-feature-services-with-geoprocessing/ and then create Python scripts which directly extract what's needed out of me map services.

Below is an example, which is running off an ArcGIS server on my desktop. It's doing what Select by Attribute would otherwise do. In this case, it's selecting a farm field boundary by name. The field boundary runs as a feature service and users draw the boundaries using the JSAPI Edit Dijit.

I'd hope that ESRI would add some more standard tools which would directly do this sort of thing. Maybe in 10.4, since 10.3 is already out the door this week...

# SelectFieldByName.py
# Get an ArcGIS server feature set
# input
# 0: FeatureService URL
# 1: Field Name
# output
# Feature Set
# Modification History
# dhh 15Dec2014 Original
import arcpy
import os
import sys
import traceback
import urllib
# Get the Parameters
fsBaseURL = arcpy.GetParameterAsText(0)
fieldName = arcpy.GetParameterAsText(1)
where = urllib.quote(r"Name='{}'".format(fieldName))
fields = '*'
token = ''
# REST query of mapservice
query = r"/query?where={}&outFields={}&returnGeometry=true&f=json&token={}".format(where, fields, token)
fs = arcpy.FeatureSet()
fsURL = fsBaseURL + query
arcpy.AddMessage("Loading {}.".format(fsURL))
fs.load(fsURL)
arcpy.AddMessage("Loaded {} finished.".format(fsURL, fs.JSON))
arcpy.SetParameter(2, fs);
answered Dec 18, 2014 at 14:54

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.