Is it possible to download a table of values from ArcGIS online that includes the subtype name rather than the value that is stored in the attribute table? i.e. when I download a table from AGOL, the deficiency field contains the values: 1, 2, 3 instead of culvert, signs, debris
Solved! Go to Solution.
I don't have a link to a blog, but let me show you what I did step by step. Hopefully it helps.
On the Data tab of the feature layer, top right corner will have "Table" & "Fields", select "Fields".
It will take you to the attributes fields, select the attribute (in your case "Type") and on my example I'd select "Manufacture" or any other attribute that has a drop-down list.
You will see the "List of Values" in the attribute(s), select "Edit"
And it'll take you to the actual list to edit. Maybe the person who originally set up the feature layer did the Label = 1, Code = Culvert. This is how you would find out how the list is set up. Now if it's Label = Culvert, Code = Culvert and still showing up as a digit, I'm not too sure about that.
Depending on how you're downloading the data and what your workspace looks like, you can fairly easily pull the domains and aliases from the service properties and use them as replacement values. Here's something I do in Python:
service = gis.content.get('some-itemid').layers[0]
aliases = {f'{i["name"]}':f'{i["alias"]}' for (i) in service.properties['fields']}
domains = {i['name']:{str(j['code']):j['name'] for (j) in i['domain']['codedValues']} for (i) in service.properties["fields"] if 'domain' in i and i['domain'] is not None}
df = service.query(as_df=True)
for d in domains:
if d in df.columns.to_list():
df[d] = df[d].astype('str').replace(domains[d])
df.rename(columns=aliases, inplace=True)
The output of that should be a dataframe with the aliases swapped in. You can write that dataframe to a file, layer, etc. as needed.
I'm hoping to find a solution for non-GIS users i.e. coworkers that need the data for monthly reports etc. if possible!
Hm. That is admittedly tougher to do without building custom tools.
How are your users downloading the data? You could create a Data Expression in a Dashboard in which the values all get swapped for their domain descriptions, then let the users download that. A bit convoluted, but gets your users the data they need without requiring them to run any scripts.
I believe they're using the export data button in ArcGIS Online
Did you set the list of values as "Label = 1, Code = Culvert"? If so, you can go back and update your list of values as "Label = Culvert, Code = Culvert" and when the data is downloaded/exported you won't have to worry about it showing up as 1, 2, 3. I had a similar issue too and resolved it that way (see photo).
I didn't create the original feature layer.
Do you have a link to an ESRI blog that explains how this can be done? The values appear as expected in the Data tab and I have use an Arcade expression to Decode the labels but when I download the table it still contains numbers.
I don't have a link to a blog, but let me show you what I did step by step. Hopefully it helps.
On the Data tab of the feature layer, top right corner will have "Table" & "Fields", select "Fields".
It will take you to the attributes fields, select the attribute (in your case "Type") and on my example I'd select "Manufacture" or any other attribute that has a drop-down list.
You will see the "List of Values" in the attribute(s), select "Edit"
And it'll take you to the actual list to edit. Maybe the person who originally set up the feature layer did the Label = 1, Code = Culvert. This is how you would find out how the list is set up. Now if it's Label = Culvert, Code = Culvert and still showing up as a digit, I'm not too sure about that.
Thank you! I believe that solution would work. Unfortunately, the field in this table is just an integer value and was not created as a list of subtypes as I had assumed it was. I find this really bizarre since the pop-ups show the text value, not the numbers and there doesn't appear to be any special pop-up configurations.
Interesting. I wonder if the feature layer was created from an import or if it was created from scratch on AGOL. The issue I ran into, which was kind of similar, was trying to take a shortcut and importing all our existing shapefiles, that way I didn't have to recreate all our shapefiles into feature layers from scratch. It worked to an extent, but some of the feature types (attributes) were auto-created as small integers and limited on what we could do with them in AGOL. For example, not being able to use text in the code, which would cause all exports to have an integer(s) on the tables, since the feature layer was created using the configuration of the old shapefile. You may have to recreate your feature layers, maybe create one as a test with a feature type as a "string", create a list, place some points on the map viewer, then export and see if that works for you. If it does, then recreating may be the way to go. I know it will be time consuming, but it will be worth it. Also make sure when recreating a feature layer everything is how you want it, some stuff can't be edited after the feature layer is created, like the "field type: string, integer, date, etc." or a "default value". Best of luck!
(Example: this is my original hydrant import from shapefiles)
What I ended up doing is just recreating all our shapefiles from scratch on AGOL and made sure when adding a field (attribute) I left it as a "String" that way an editable "List of Values" appears on a field.