Am I trying to do too much with Model Builder?

273
3
11-21-2011 01:23 PM
KeithAdams
New Contributor
I am trying to construct a model (or pair of models) that I can subsequently publish as an ArcGIS Server service. 

Each model needs to accept a coordinate pair as the starting point.

Having created an in-memory feature class with one point based on the input coordinates and a pre-set spatial reference, one branch of the model (or one of the two models) would do a spatial join against a polygon layer to determine the "most likely" feature, if any, into which the point falls.

The second part, or the second model, would create a buffer of predetermined radius around the point, then do an intersect against the same polygon feature layer to determine whether the result obtained from part 1 is "realistic", or whether there might be alternate results based on positional uncertainty of either the point location or the line location (i.e. the point is too close to a boundary line for the point result alone to be considered "definitive" based on inherent uncertainty in location of point, boundary, or both).

PROBLEM NUMBER 1: I cannot find any tool or combination of tools that can be used, abused, or otherwise manipulated to create a point feature from coordinates (even disregarding the need for a spatial reference- I can specify that.)  Preferably the feature would be an in-memory feature rather than written to disk, but I cannot find anything one way or another.  I've tried creating an event layer, but that starts from a table and there is no tool that I could find which can be used to add rows to a table.

PROBLEM NUMBER 2: Assuming I could somehow find a way to create an event layer, I really need a feature class in order to do a spatial join.  How do I get from the event layer to an actual by-gosh feature class?  Again, bonus points if it exists only in memory, and only for the lifespan of model execution.

PROBLEM NUMBER 3: Having now succeeded in creating this fantasy in-memory feature class, I want to create an equally fantastic in-memory BUFFER layer.  Again, no tool I know of will do this in memory- the buffer tool wants to write to disk.  Perhaps all of this is serialized and happens in memory only when the model is published as an ArcGIS Server service?

PROBLEM NUMBER 4: I don't yet know what the problem will be but given the way this process has gone so far I'm sure there is something else I have overlooked.  Any idea what it might be?
0 Kudos
3 Replies
markdenil
Occasional Contributor III
Yes, you are expecting too much from model builder.

Model Builder is great for quick prototyping, especially of the parts of a larger system, but it is a bit flaky for stuff you want to rely upon.

The answer is spelled PYTHON (and pronounced 'Throut-warbberler-mangrove')(please forgive the obscure Monty Python reference).

Python can do all the things you need (create features from coordinates, create and delete scratch spaces, ect), and can also handle errors so your process can fail gracefully.

I believe that an Arc Server service creates its own scratch space for temporary files...
0 Kudos
ColinLindeman
New Contributor II
Aloha Keith,

I am trying to do something similar in model-builder. I want to have a user input of x,y that will then be 'projected' followed by a 'multi-ring buffer' to generate zones to use in 'zonal stats as a table'.

For the x,y user input, I found an ESRI reference for 'Record Sets' which is at http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/A_quick_tour_of_using_Feature_Set_and_...

To make the 'record set' interact-able you have to define a schema for it. Read more about creating a schema here http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//002w00000069000000

After you publish the geoprocessing service you use the rest input notation, which you can find here http://atlas.resources.ca.gov/ArcGIS/SDK/REST/gpsubmit.html It looks like this {"features" : [{"attributes" : {"x_value" : "122.20", "y_value" : "47.37"}}]} and will differ depending on the defined schema or if no schema is set.


Now with my model I am running into issues with using %SCRATCHWORKSPACE%/scratch.gdb (which resolves to a folder under C:\arcgisserver\arcgisjobs\geoprocessing which is where AGS uses its scratch workspace) My model fails when trying to do the multi-ring buffer, which error reporting indicates that it can not find the projected input data. I'm not really sure what is going wrong yet.

Hope this helped somewhat. I may write this script solely in python and use a different method for getting the x,y user input since I have had more success in the past going that route.

-Colin Lindeman
0 Kudos
DaleHoneycutt
Occasional Contributor III
As suggested, use a Record Set  to capture xy coordinates as strings.  Use Make XY Event Layer to turn the table row (the Record Set) into a feature layer.  Use the Copy Features tool to copy this layer to a feature class.  The Copy Features tool honors the output coordinate system environment, so you can change the coordinate system here if need be.  You can write the output feature class to memory using the in_memory workspace.  You can buffer this point using the buffer tool, but again, write the output to the in_memory workspace.
0 Kudos