Select to view content in your preferred language

Download data with subtype name

1241
9
Jump to solution
10-28-2022 09:43 AM
by Anonymous User
Not applicable

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

0 Kudos
1 Solution

Accepted Solutions
fjramos
Frequent Contributor

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".

fjramos_1-1667304999497.png

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.

fjramos_2-1667305125813.png

You will see the "List of Values" in the attribute(s), select "Edit"

fjramos_3-1667305195902.png

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.

fjramos_4-1667305244368.png

 

 

 

View solution in original post

0 Kudos
9 Replies
jcarlson
MVP Esteemed Contributor

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.

- Josh Carlson
Kendall County GIS
0 Kudos
by Anonymous User
Not applicable

I'm hoping to find a solution for non-GIS users i.e. coworkers that need the data for monthly reports etc. if possible!

0 Kudos
jcarlson
MVP Esteemed Contributor

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.

- Josh Carlson
Kendall County GIS
0 Kudos
by Anonymous User
Not applicable

I believe they're using the export data button in ArcGIS Online

0 Kudos
fjramos
Frequent Contributor

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).

0 Kudos
by Anonymous User
Not applicable

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. 

SHartholt_1-1667302468096.png

SHartholt_2-1667302495528.png

 

0 Kudos
fjramos
Frequent Contributor

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".

fjramos_1-1667304999497.png

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.

fjramos_2-1667305125813.png

You will see the "List of Values" in the attribute(s), select "Edit"

fjramos_3-1667305195902.png

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.

fjramos_4-1667305244368.png

 

 

 

0 Kudos
by Anonymous User
Not applicable

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.

SHartholt_0-1667312701504.png

 

0 Kudos
fjramos
Frequent Contributor

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)

fjramos_0-1667332508953.png

fjramos_1-1667332562860.png

 

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.

fjramos_4-1667333343451.png

 

fjramos_2-1667332634833.png

fjramos_3-1667332693500.png

 

 

0 Kudos