1

I have a feature service with several coded value domains that I'm accessing as a spatially enabled dataframe using the python API.

As far as I can tell, the dataframe only holds the code for each field. I'd like to update those to the description from the domain. Is there a way to access the domain of the feature service through the API?

2

I am not aware of a functionality in the ArcGIS API for Python to accomplish this. However, you can do a workaround and get the values by querying the domains of the feature service using the ArcGIS REST API.

Using Python you would simply make the following request:

import requests

url = 'https:// <featureservice-url>/queryDomains'
params = {'f': 'json', 'layers': [1]}

r = requests.get(url, params)
data = r.json()

If the request was made correctly, data should be a dictionary similar to this one (adapted from the documentation linked above):

{
 "domains": [
  {
   "type": "codedValue",
   "name": "CDOM_3",
   "fieldType": "esriFieldTypeInteger",
   "codedValues": [
    {
     "name": "code 100 description",
     "code": "code 100"
    },
    {
     "name": "code 200 description",
     "code": "code 200"
    },
    {
     "name": "code 300 description",
     "code": "code 300"
    }
   ],
   "mergePolicy": "esriMPTDefaultValue",
   "splitPolicy": "esriSPTDefaultValue"
  }
 ]
}

It should then be rather straight forward to replace the coded values with their respective descriptions in the DataFrame. However, if it is not the case and you have trouble, leave a comment and I'll gladly update my answer.

  • 1
    For whatever reason the /queryDomains request returns a 400 error. Is it possible for a feature service to not have it enabled? However, your answer led me to just grabbing the JSON for the layer, which also has the domains listed for each field. Thanks! – Cameron Dean Jun 25 at 17:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.