I am wanting to setup a layer for capturing tree plots.
I would like to create a choice list for the tree species. I have the list of species in a csv file but I can't find way to upload it into the feature layer as a pick list.
Is there a way to this?
Any help would be appreciated.
I have not seen a way to automatically do this in ArcGIS Online! The only way I have see to create a pick list of values in a feature layer in ArcGIS Online is to:
If you're using ArcGIS Field Maps, it will show up as a list picker on the GPS Unit/iPad - or if you are doing some other type of data collection.
Not sure if there is an alternative way to do this! Like with a pre-created CSV file that you can upload to the site to create the Feature Layer - I've tried a few different methods, but nothing was successful. I think manually creating the list might be the only option.
Good luck with your project!
You can use the python API for this. Just need to convert the csv to json dictionary formated as below.
Here is what I use with subset of MUTCD codes for example:
from arcgis.gis import GIS
#JSON dictionary of the Domain Code/Values
# Replace FieldName with the name of the field you want the list on
update_dict = {"fields": [
{
"name": "FieldName",
"domain": {"type":"codedValue","name":"FieldNameCodes",
"codedValues":[
{"name" : "Unknown", "code" : "Unknown"},
{"name" : "Custom (Warning)", "code" : "Custom (Warning)"},
{"name" : "W16-13P", "code" : "W16-13P"},
{"name" : "W17-1", "code" : "W17-1"}]}}]}
# Connect to your AGOL account
my_agol = GIS(url='https://yourOrgHere.maps.arcgis.com/', username='AdminUser', password='AdminPass')
# Get the first layer - Layer 0 - of your Hosted Feature Layer with ID <HFL_ID>
# Change this to the layer number you want to modfy the Choice List for
lyr = my_agol.content.get('asdagaasf54ahghdf').layers[0]
update = lyr.manager.update_definition(update_dict)
This does not add to the list, but overwrites it. So, I keep the json list in text editor so when I need to modify it, I just copy/paste into the script.
This is also the easiest way I have found to add somehting to the list and don't want it at the end. After running this script, choice list is sorted in the order of the update_dict json.
R_