Sort Domain Alphabetically in ArcGIS Online

832
28
06-22-2021 08:11 AM
JasonBritton1
Occasional Contributor

Hello all. I've got a Coded Value list of street names in and AGOL feature service. The list has grown to over 1200 and as a matter of convenience, I'm tired of having to scroll to drop the new value in its appropriate location. Anyone have a fix to sort the list of of values with a couple of clicks? 

28 Replies
JansenLyons
Occasional Contributor II

That's bizarre. It may be an area minimum requirement or agency level of government or company access perhaps. DM me if you hear back, when I upload next I will take this into consideration if it's an issue for whatever reason. 

Back on topic though, do any of these help? If one topic or the other helps more we can dive into that in more focus for example. 

Jansen Lyons - Records and GIS Section - Public Works - City of Rio Rancho, NM
0 Kudos
JasonBritton1
Occasional Contributor

Nothing suggested seems really viable so far. I posted on reddit as well and someone created a sample codeblock to use. I suck at python so I'll have to stumble around and see if I can get it to work. 

JoeBorgione
MVP Esteemed Contributor

post it and lets have a look....

can't wait to retire....
JasonBritton1
Occasional Contributor

from arcgis.gis import GIS gis = GIS("home") # Open the layer from arcgis.features import FeatureLayer MY_LAYER_URL = "https://services6.arcgis.com/your/full/path/here/FeatureServer/0" layer = FeatureLayer(MY_LAYER_URL, gis=gis) # Get the field definition. MY_FIELD_NAME = "yourFieldName" targetFieldDef = None for fieldDef in layer.properties["fields"]: if fieldDef["name"] == MY_FIELD_NAME: targetFieldDef = fieldDef break # Get the Coded Value List, sort it and push it back on the field def. codedValues = targetFieldDef["domain"]["codedValues"] sortedCodedValues = sorted(codedValues, key=lambda cvPair: cvPair["name"]) targetFieldDef["domain"]["codedValues"] = sortedCodedValues # Get the layer's manager interface and modify its definition. layerMgr = layer.manager updatedDef = {"fields": [targetFieldDef]} layerMgr.update_definition(updatedDef)

JansenLyons
Occasional Contributor II

Is there a planned streets layer you could draw out of in combination to existing instead of updating the layer 2 days a week? It seems too complicated for what it should be, I am not nearly code-savvy enough to implement this but I follow the syntax well enough. Civil authorities will change or add names as they need to with request/petition/growth, and this is not to say growth can outstrip this, but I am curious if there are more pragmatic planning and delivery methods of this data than having 2 days a week dedicated to this work. Seems grueling but unfortunately realistic in today's market and such. On note of the code is there an editing group involved with this or is it just you?

Jansen Lyons - Records and GIS Section - Public Works - City of Rio Rancho, NM
0 Kudos
JasonBritton1
Occasional Contributor

There is a group of about 20 editors for this particular layer. There definitely has to be a better way, but I don't know what it is. The positive part is that I don't dedicate a full two days a week to it, but rather work on it maybe for an hour or two on the days I add roads. This is actually related to a point file used for water meter sets and drop ins where the field crews are required to input the billing address associated with the meter. Workflow is that I create the new centerline and then I have to add the new road name to the meter layer. 

JoeBorgione
MVP Esteemed Contributor

I can't really make heads or tails out of that code either even after putting in my python ide.

can't wait to retire....
JasonBritton1
Occasional Contributor

Me either. 

JansenLyons
Occasional Contributor II

Well, the day is young and I would say keep on it as others reply to this or your Reddit post. Keep us posted, glad it's just a few hours at a time than 48-ish straight over work periods. Thanks for posting & thanks to @JoeBorgione . This has been most interesting.

Cheers @JasonBritton1 

Jansen Lyons - Records and GIS Section - Public Works - City of Rio Rancho, NM
0 Kudos