Setting up a geoprocessing service

351
6
02-05-2013 09:59 AM
SamuelHenderson
New Contributor II
Hello all,

First let me say that although I've done quite a lot of work on ArcEngine and ArcObjects stuff I have never dealt with geoprocessing services.

What I need to do is set up a geoprocessing service that will be accessible by an ASP.Net webpage.  What will happen is that a user will enter information on a series of webforms.

The current workflow is like this:

  1. User enters data into webform

  2. The website saves the data to a standalone SQL Server Database

  3. The user closes the webpage, opens arcmap, adds a new point to a Layer/featureclass in our SDE Geodatabase and then fills out all the fields for the point with the data just entered on the webform.

What I would like to do is something like:

  1. User enters data into webform

  2. When the webform is saving the data to the database it calls a geoprocessing service to create the point and add the data automatically so the user doesn't have to mess around in arcmap.  Ideally I don't want the user (who is not a GIS technician) to see a map at all.

I've already ensured that my organization has the required ArcServer license to do this ... So what's the best way to accomplish what I am trying to do?  I looked into the Data Management Tools of ArcMap's Geoprocessing ArcToolbox but I didn't see any way to modify a featureclass (aside from creating random points).  I'm pretty handy at Python and ArcPy so if needed I can whip something in that as well.
0 Kudos
6 Replies
KevinHibma
Esri Regular Contributor
Well I guess my first question is how do they enter a "point"?
Because you said no map, it sounds like they're entering an X/Y coordinate?
If thats the case its a pretty basic model with 2 tools, Make XY Event Layer and then you could use the Append or Merge tool to combine that output into your existing featureclass.

Or if you are adding those webforms into the FC attributes, a more straight forward way could be to write a Python script. You can use an arcpy function to create the geometry, and pass in the values as strings or longs into an InsertCursor. You could do that directly on the FC you want to update or you could persist the arcpy geometry into a feature and then use append or merge.

Hope these ideas help.
0 Kudos
SamuelHenderson
New Contributor II
Thanks for the reply Kevin :)

Yeah I should have mentioned how the coordinates for the point are coming in to play.  Basically part of the form includes address fields (we have all the addresses already geocoded).  So I guess if we go this route what would have to happen is that we would look up the address and get its point's coordinates.  Then use those coordinates for our new point :)


Or if you are adding those webforms into the FC attributes,



Yeah this is essentially what we are doing, adding a point and then filling out it's attributes. 

a more straight forward way could be to write a Python script. You can use an arcpy function to create the geometry,

I like this idea of making a python script to insert the data as I've already made similar arcpy scripts.  The only question I have about this approach is how do I invoke that python script?  I'm assuming that I can't just have my aspx.vb page run shellexecute on the python script and pass the fields as parameters... That would be some kind of license violation right? 

and pass in the values as strings or longs into an InsertCursor. You could do that directly on the FC you want to update
  This makes me thinks that I am misunderstanding how the Python script is triggered.  It's not my website calling the python script directly right?  I'd have to go through some geoprocessing stuff before it gets to the script. 

or you could persist the arcpy geometry into a feature and then use append or merge.
  I'm afraid you've lost me here.  Persist arcpy geometry into a feature?  Not sure I follow what that means...

Thanks again for taking the time to educate me about my options.  I feel confident we can get this figured out :)
0 Kudos
KevinHibma
Esri Regular Contributor
I dont know about that getting around licensing or anything - mainly because I dont know if its possible.

Since you have ArcGIS Server and you want people through a browser (whether internally or externally) to consume the page, add some information and have something "done" to a featureclass, you can make use of a couple different service types.

If you use a FeatureService you can allow people to push features and attributes down into a FC as well as make updates. You can do the same with a geoprocessing service. A GP service is basically a tool which is one of: a system tool, a chain of tools in ModelBuilder, a Python script or some sort of function tool (.DLL).
Either the GP Service or FeatureService could be done... and they both have pros and cons. I'm not sure I'm in a position to lean you one way or another. (I'm biased towards GP because thats my focus area).

I'd give a read about FeatureServices to see if they do what you're after. (This would mean either getting a Flex or Silverlight viewer, or building a page in Flex, JavaScript or Silverlight from the ground up)

If you want to go the GP way and already have a Python script that does some or all of this, you just need to turn it into a script tool. A good starting place is here. After you have a tool, you can eventually get that into a Geoprocessing Service. To consume the service you'd again need a client application (the same as the feature service). The pattern of "using" these services would be different, but the overall design and use of the webpage you make would be the same.
0 Kudos
SamuelHenderson
New Contributor II
Thanks again Kevin!

If you use a FeatureService you can allow people to push features and attributes down into a FC as well as make updates. You can do the same with a geoprocessing service. A GP service is basically a tool which is one of: a system tool, a chain of tools in ModelBuilder, a Python script or some sort of function tool (.DLL).
Either the GP Service or FeatureService could be done... and they both have pros and cons. I'm not sure I'm in a position to lean you one way or another. (I'm biased towards GP because thats my focus area).  I'd give a read about FeatureServices to see if they do what you're after. (This would mean either getting a Flex or Silverlight viewer, or building a page in Flex, JavaScript or Silverlight from the ground up)


I'm pretty committed to going  the GP route as we don't want to have to redevelop the existing (and functioning) .aspx web page and form.  I've also already submitted my proposal recommending using a GP service :)

If you want to go the GP way and already have a Python script that does some or all of this, you just need to turn it into a script tool. A good starting place is here. After you have a tool, you can eventually get that into a Geoprocessing Service. To consume the service you'd again need a client application (the same as the feature service). The pattern of "using" these services would be different, but the overall design and use of the webpage you make would be the same.


Cool.  I think I mostly follow what you are saying here...  How would I turn my python script tool into a geoprocessing service?  Also, what would the client application be?  I'm assuming the client application would be the webpage itself which would consume the geoprocessing service and pass the data as arguments somehow?
0 Kudos
KevinHibma
Esri Regular Contributor
Cool. I think I mostly follow what you are saying here... How would I turn my python script tool into a geoprocessing service? Also, what would the client application be? I'm assuming the client application would be the webpage itself which would consume the geoprocessing service and pass the data as arguments somehow?


Correct, the "client application" is the webpage.
The webpage has the code to consume the service.

As for your script, you first turn the script into a tool (script tool). Once you have that you turn the tool into a geoprocessing service.
I'd start here with creating a script tool. Basically you just need to make the tool accept some parameters (your X/Y coordinate and string values).
Once you have a working tool, you publish it. The quick tour on publishing a GP service is a good first topic to read.
And after you've published the service you add the code to your webpage to consume the GP Service. You say you're using a aspx.vb page. I'll make the assumption that you can consume or talk to a REST end point through this? We have Javascript, Flex and Silverlight APIs. As long as you can make your page talk to the Service End point in a similar manner as one of those APIs, your page can send the input off to the GP Service. Heres a link to GP Rest help. Heres a sample which takes an actual input point on a map, as well as 1 text parameter and passes that info to a GP service (written in JavaScript).
0 Kudos
SamuelHenderson
New Contributor II
Thanks Kevin!

I understand everything you are saying.  I took a look at the 'Message in a Bottle' sample you provided which helped me further conceptualize what I'll need to do for my own site as well as see how the parameters were being encapsulated (I've actually heard of Dojo before and I think someone else in my office is more well versed in it than I.). 

One thing I noticed was that the sample javascript had a 'GP' object which seemed to be responsible for consuming the gp REST service along with the params in.  This is the functionality I will need to duplicate in my VB.Net code correct?  I suppose I'll have to read up on consuming REST services in VB.Net ... but I'm sure I can figure that out.

Thanks once again Kevin!  You did a terrific job in breaking this down into steps so that a layman like me can understand!
0 Kudos