Select to view content in your preferred language

Custom tool taking user input when geocoding

470
3
04-05-2023 09:17 AM
AnisBoughanmi
New Contributor

I'm developing a GIS script for my office that will take a ".csv" table containing addresses and generating a heat map from it. I'm able to get the code running when I "hard code" the values, but what I want to do is turn the script into an ArcGIS tool which would take user input. The script has a geocoding component, and this is where I feel stuck.  I can't figure how to modify the tool parameter in ArcGIS so the user can which fields from the  input table contains the address (street name, city etc), similarly to the actual Geocoding tool. Is there a way to do this or do I have to drop the geocoding component from the script ?

Hope this make sense.

Thanks,

Anis

0 Kudos
3 Replies
by Anonymous User
Not applicable

You can do this by using isAltered() on the parameter (the one assigned for csv input) in the tool validation class. If it’s altered (csv loaded) then get the header of the csv and set the next parameter using the filter, to be the value table (multi-input) or list for the user to select from. Then you’ll have to take those selections, parse them, and map to your geocoder. I can post an example in a few hours.

0 Kudos
by Anonymous User
Not applicable

Here ya go- a simple script tool to demonstrate getting the fields from the csv dynamically. Check the Validation code for where it needs to be done.  From there, you can map the field to the geocoder in the execution code from parsing the parameter(1) list.

0 Kudos
AnisBoughanmi
New Contributor

Sorry for taking that long to respond. I kind of gave up on this and forgot to check any new answers. I will definitely try that method and let you know if that worked.

0 Kudos