Select to view content in your preferred language

Setting Feature Layer as Default in Geoprocessing Service written in Python

2250
10
02-19-2020 07:09 AM
by Anonymous User
Not applicable

Hello! I have a python script for a geoprocessing service. It takes all of the streams that lie inside of polygons selected from up to three different feature layers and runs different calculations (total length, cost, etc.).Currently, when you open the tool (in a widget), you have to specify each of the feature classes for each parameter. That is, there are three drop-down boxes under headings (HUC8, HUC10, County), and you have to select the correct feature class for each parameter.

What I would like to do is have each parameter default to a certain feature class so the user doesn't have to do it each time. I feel like this should be easy, but I can't figure it out (plus, I'm still very new at Python scripting.).

Should this be written in the script, or does it have to be set when the script is served online? Or...?

The script was written for Python 2 to be used in ArcMap (as opposed to ArcPro).

I know more information is needed to help you all answer my question. Please specify what more you need!

Annina

0 Kudos
10 Replies
by Anonymous User
Not applicable

Thanks for the explanation, Vicky. I think though there's still something missing, and it may be due to how the script was written. 

As far as I can tell, the parameters aren't set in the script; they are set when creating the toolbox in ArcMap. There are three parameters that are entered into the tool, HUC8, HUC10, and County. These three parameters are all set as "Feature Set" and type: Optional. Unfortunately, if the Data Type is "Feature Set," you can't set a Default (like you can with feature layer, shapefile, etc.), and there is only one Filter option: None.

I have tried running as other Data Types; some won't run at all. The most promising one was "Any Value" because it allowed me to run the tool with defaults set. When served, it did enter the correct defaults, but I lost the capability of making selections in the layers. That is, the tool would run all three layers at their max extent. We need people to be able to choose subsets because the tool will then make calculations based on those.

Does this make sense? Am I expecting more than what can be done? If you'd like to see the tool as it stands now (running, but the user has to manually set each layer and then make the selection), I can share it with you.

0 Kudos