I have published the following script tool (which is wrapped in a model, i.e. just the script tool and all of its parameters) to ArcGIS Server 10. The GP service succeeds when run, but I cannot determine how to access the final output of the GP service. The result is a RecordSet object, and I can view it in the arcgisjobs/job-id/ directory when viewing it on the server.
However, I cannot figure out how to access the result via the REST API. As you can see, the script tool doesn't have an output parameter. When viewing the GP service via the REST Directory there are only the two inputs. I have tried using SetParameterAsText and a Result object and adding an output parameter to both the ST and the model but without any success. So, the question is how do I modify the script and/or script tool/model properties to designate an output parameter so that it can be accessed via the REST API and subsequently consumed in a web application?
I have read through this related question but it has not helped.
The REST Endpoint: http://atlas.utc.edu/ArcGIS/rest/services/RRI/DE/GPServer/Decision%20Engine
The Python script:
#Import ArcPy site package module import arcpy from arcpy import env from arcpy import Extent from arcpy import Raster from arcpy import RecordSet from arcpy.sa import ZonalStatisticsAsTable from time import gmtime, strftime # Check out ArcGIS Spatial Analyst extension license arcpy.CheckOutExtension("Spatial") # Set Environment Workspace ws = env.workspace = WORKSPACE PATH # Set Environment Raster Cell Size cellSize = env.cellSize = 10 # Set Environment Processing Extent processingExtent = Extent(602560.330672585, 3827530.65305605, 746490.330672585, 3966810.65305605) environProcessingExtent = env.extent = processingExtent # Strings representing rasters in the workspace rasters = arcpy.GetParameterAsText(0).split(";") # The dataset that defines the zones inZoneData = arcpy.GetParameterAsText(1) # Determine Zone Dataset if inZoneData == "Block Group": zoneField = "Value" zoneData = ws + "\\ToolData\\Data.gdb\\BG_Ras" elif inZoneData == "Census Tract": zoneField = "TRACTCE10" zoneData = "\\ToolData\\Data.gdb\\CT_Ras" else: zoneField = "" addedRaster = Raster(ws + "\\ToolData\\Data.gdb\\constantRaster") # Process each raster string for raster in rasters: addedRaster = addedRaster + Raster(ws + "\\ToolData\\Data.gdb\\" + raster) # Execute Zonal Statistics zonalTable = RecordSet(ZonalStatisticsAsTable(zoneData, zoneField, addedRaster, "%SCRATCHWORKSPACE%\\zontalTable", "DATA", "MAXIMUM")).save("%SCRATCHWORKSPACE%\\rszt")
Some relevant images?
Script Tool Parameters
Model Tool Parameters