Select to view content in your preferred language

Erase GP

4452
13
01-13-2016 07:50 AM
Srinivasa_MurthyNemani
Emerging Contributor

Hi,

I created a simple GP and published as GP service, i executed the service using submit job, but nothing happen's

import arcpy

try:   

    arcpy.env.overwriteOutput = True

    arcpy.env.workspace = "C:\\geometry\\test.gdb"

    polygonFC = "drawPoly"

    eraseFC = "testFC"

    outFC = "outFC"

    singlePart ="outputSP"   

    arcpy.Erase_analysis(polygonFC,eraseFC,outFC)   

    arcpy.MultipartToSinglepart_management(outFC,singlePart)

except:   

  error = arcpy.GetMessages() 

where am i'm i going wrong.

0 Kudos
13 Replies
XanderBakker
Esri Esteemed Contributor

You don't have to import another module. There is no need in your script. However, the %scratchworkspace% will probably not work. This looks like how you would use it in ModelBuilder. See Using the current and scratch workspace environments—Help | ArcGIS for Desktop .

Your script is probably the script before publishing. I would be more interested in the content of the script after publishing it to ArcGIS for Server. There is a big difference between running scripts locally and publishing them as geoprocessing services. And during the publishing process the chances are high that the content of the script is changed by ArcGIS. You may be interested in this topic: Authoring geoprocessing tasks with Python scripts—Documentation (10.3 and 10.3.1) | ArcGIS for Serve...

The other part is the data and access to it. Do you have a folder C:\test with the data on you server? Did you choose to copy data to the server during the publishing process. You may want to read up with this topic: Make your data accessible to ArcGIS Server—Documentation (10.3 and 10.3.1) | ArcGIS for Server

The script is currently using the same data for its process. Do you want to make it variable? Please read: Accessing parameters in a script tool—Help | ArcGIS for Desktop

If not you may want to consider construct a simple Model in ModelBuilder, run it and after a succesful run, share it as a geoprocessing service. A quick tour of authoring and sharing geoprocessing services—Sharing geoprocessing workflows | ArcGI... . Although having a geoprocessing service that will create the same output every time it runs, does not sound very useful to me.

Srinivasa_MurthyNemani
Emerging Contributor

Hi,

Thank you for the detailed info, its really useful.

My basic requirement is i want to implement overlay analysis using Javascript API, i found out that there is a dependency of Portal for arcgis for implementing the same.

OverlayLayers | API Reference | ArcGIS API for JavaScript

So I've decided to write a python script for this purpose, and all my process has to happen backend, so there are no parameters declared, data is directly read from SDE/GDB/.SHP.

Now once my GP service is ready, i want to implement this using a Geoporcessor object in Arcgis Javascript Api.

And all this process should take place on a button click for a web application.

I'm stuck with the GP service.

0 Kudos
XanderBakker
Esri Esteemed Contributor

Question (although I'm slowly exiting my comfort zone)... Would it be possible to implement the Geometry Service? Although I didn't see the option to apply an Erase, the same effect can be obtained by doing a Union and selecting the features you need. GeometryService | API Reference | ArcGIS API for JavaScript . Maybe that could be another question to put in ArcGIS API for JavaScript

What I would like to know, are the data you are referring to in your script static? If so then I don't really understand why you would want a GP service to create the same output every time it runs. If not you should work with parameters to specify the data to use in the process. The other point is that you will probably have to use the arcpy.SetParameter (SetParameter—Help | ArcGIS for Desktop ) so that your application will be able to get the result from the operation.

I´m still interesting to see what ArcGIS for Server did to your script while publishing. You should be able to find the script in a folder like:

\\ServerName\arcgisserver\directories\arcgissystem\arcgisinput\FolderName\ServiceName.GPServer\extracted\v101

0 Kudos
JamesCrandall
MVP Alum

So I've decided to write a python script for this purpose, and all my process has to happen backend, so there are no parameters declared, data is directly read from SDE/GDB/.SHP.

What is going to happen when there are many concurrent users?  Each successive one will be overwriting what the last execution created?  I'd think each should get their own result (output parameter).

0 Kudos