Publishing a GP Service with an Operational Layer

1892
13
Jump to solution
05-30-2018 12:24 PM
BlytheSpendlove1
New Contributor III

I am trying to publish a geoprocessing service that takes an input file from a web application, does a custom field calculation based on user defined integer inputs, and outputs a feature service that can be viewed and exported from the web application.

However, when I publish my geprocessing service and bring it into Web AppBuilder using the geoprocessing tool widget, I cannot choose the option "Add result as operational layer" and the output has the error "Can not set renderer because of unknown geometry type."

This is the REST URL for my geoprocessing service: WetlandPrioritization/WetlandPrioritizationTool_Ac (GPServer), and the screen shot below show my output parameter as having no geometry type.

Question 1) Does anybody know why I cannot see the geometry type? I am assuming this is the reason I cannot add my result as an operational layer.

Question 2) I am assuming the error above is why the tool will not run. But I also realized that I am using the python math module in my python script....Is that a problem? Do I need to download that module somehow onto my server, or can I assume the math module will work in the gp service?

My workflow for creating the Geoprocessing Service:

I created a script tool with a Feature Layer as the input, and a Feature Class as a derived output. 

I then ran the tool in ArcMap (10.5) and published the geoprocessing service onto my organization's server (version 10.5). For Parameters in the Service Editor, I chose "Asynchronous" and "View results with map service," as I believe I can view the gp service results as a map service in addition to whatever my normal outputs are (such as an operational layer). I also specified maximum number of records returned by the server  as 3000 because I have 2313 features in the input feature class that will be used by the tool. I then published the tool. 

I have attached the source code that my web tool is running.

Thanks!

0 Kudos
1 Solution

Accepted Solutions
JonathanQuinn
Esri Frequent Contributor

Hey Blythe

When you ran the GP tool in ArcMap, were the results added to the display? Did the output show a proper geometry symbol?

Ex.

Generally, how it behaves in ArcMap is how it'll behave as a service. I'd say the problem is definitely that the Geometry Type is null.

This isn't related to the math module, as you'd see an ImportError when running it on the Server. Can you upload the toolbox?

View solution in original post

13 Replies
JonathanQuinn
Esri Frequent Contributor

Hey Blythe

When you ran the GP tool in ArcMap, were the results added to the display? Did the output show a proper geometry symbol?

Ex.

Generally, how it behaves in ArcMap is how it'll behave as a service. I'd say the problem is definitely that the Geometry Type is null.

This isn't related to the math module, as you'd see an ImportError when running it on the Server. Can you upload the toolbox?

BlytheSpendlove1
New Contributor III

Hey Jonathan!

The results were added to the display in ArcMap when I ran the tool. I then changed the symbology of the results and exported the geoprocessing service. When I try and run it as a service in a web application though it doesn't work. I click the button to execute the model and the button grays out for a bit and then it goes back to normal, as if the service timed out or something.

Great to know that the math module is fine. 

Attatched is the toolbox.

Thanks!

Blythe

0 Kudos
BlytheSpendlove1
New Contributor III

Oh whoops I was looking at the wrong thing. The output actually did not show a proper geometry symbol when I ran it in ArcMap.

0 Kudos
JonathanQuinn
Esri Frequent Contributor

Ok, that's why the service doesn't have geometry. Can you try to republish the service with the output parameter as a Feature Set, instead of a Feature Class? Theoretically, they should be the same, but that's a simple test to run. If that doesn't work, can you upload a sample input as well as parameter values I can use to try it out?

0 Kudos
BlytheSpendlove1
New Contributor III

Alright so it didn't work as a Feature Set, but then when I specified the output in the script tool parameters as Feature Layer, and also specified that the derived output was obtained from the output layer, it worked! It showed the proper geometry symbol in ArcMap when I ran it and when I used the geoprocessing service in Web AppBuilder the tool did not have any issues with the geometry type either! It let me change the default symbology and everything. It still doesn't work haha, but the geometry issue is solved now

This is how I edited the output parameters:

0 Kudos
JonathanQuinn
Esri Frequent Contributor

Not sure if you've addressed this yet, but your 6th parameter, (Output Layer Name), is set as a Feature Class, which may cause issues if you're using that value to create the path to the output.

BlytheSpendlove1
New Contributor III

Oh yeah, I did change that. I changed it to string. Thanks!

0 Kudos
JonathanQuinn
Esri Frequent Contributor

Hm, I would also use arcpy.env.scratchGDB over "%scratchworkspace%/scratch.gdb/", layerOutName:

Ex.

layerOut= os.path.join(arcpy.env.scratchGDB, layerOutName)

It's a bit cleaner and I'm not sure how well the Modelbuilder approach of %<output>% works in python script tools.

BlytheSpendlove1
New Contributor III

Oh thank you! That might be the thing that is still causing me problems when I try and run the tool. I'll change that now and see if that works. (Right now I am getting a generic "Unable to complete operation" error).

0 Kudos