AnsweredAssumed Answered

Problem with input (dynamically choose layer) and output (save to file) for geoprocessing tool in Portal

Question asked by H.Bouckaert_westernpower on Jul 4, 2018

Hi 

 

I am having a lot of difficulties in configuring input and output parameters for a geoprocessing service to be accessed by the geoprocessing widget in Portal. I have tried for two days now and it looks like I have exhausted all options and yet, what I am trying to do seems rather straightforward.

 

I would like to source a single input polygon from a web map in a Portal application as my input. Then I would like to create a PDF and save it, using the attributes that belong to that particular polygon.

 

Firstly input: I run my python script in a toolbox with an input parameter set to "Layer" type - I also tried "Feature Layer". I have tried publishing this after running the tool directly as a python script in a toolbox, but also have put the script in a model and then set the input parameter of the model dynamic with the "P" option. In the desktop environment, the script and the model work  and allow me to dynamically choose the input layer in ArcMap. Once I have run this, I either use the results from running the script or from running the model, and select  "Share as a geoprocessing service" and publish to Portal.

      

When publishing to Portal, for the input mode I choose "Choice List" (the documentation says that this allows you to select dynamically from a map) . But I have noted that in all cases there is a warning that during publishing the data will be uploaded to the server. That is not a good sign but there seems to be no way to avoid this (except using a registered folder I suppose). Once the geoprocessing service is published, I access the rest geoprocessing URL from the geoprocessing widget in WAB. But when I try to use dynamic input in the geoprocessing tool in WAB, I cannot choose anything from the map. During publishing I also tried "User Defined Value" and "Constant Value" as publishing options but none of this allows me to do anything interactively in the map afterwards. Ideally I would like to highlight one polygon and use that as my input (single polygon to be processed by the geoprocessing tool). How can this be done? Note that in the original python I have my input parameter as

 

Layer = arcpy.GetParameterAsText(0)

and in the toolbox, I specify as my input type "layer" or "feature layer". Is this wrong? 

 

Secondly output:  I am afraid this is quite frustrating. I would like to save the output as a file to a folder location. I know that AGS and Portal have issues with saving things out (because on the server, local paths on the desktop may not be known) but surely there must be a way. I simply do not seem to find any way at all to achieve that. There is some mention that you can save geoprocessing output back to the desktop after zipping up the output file (e.g. a PDF or a CSV zipped up) but I could not make that to work at all (and believe me I have tried). Specifically, when publishing a geoprocessing service, it is impossible to use a folder or a File geodatabase as an used-defined choice input parameter. I also tried to set a variable to "output" in the toolbox before publishing.  Lastly, in the script I have tried to set my output to arcpy.env.scratchFolder. Although all this works on the desktop, none of this works after publishing the same script as a geoprocessing service.  So there seems to be no options to provide me with saving a file to some location when running the geoprocessing service in WAB. It seems the output file simply disappears or is not generated at all. I have no visibility on that. 

 

So in short any help in particular a code example (plus publishing instructions) would be most welcome, to 

 

1. enable the geoprocessing tool to dynamically select a polygon from an input layer in a web application and

2. enable file output to be saved to a location of the user's choice

 

Anybody's help will be greatly appreciated.

 

Thanks very much 

 

Hugo  

Outcomes