0

I have access to an ESRI MapServer that contains several layers; how can I get the values out of those layers and export it?

Example:

MapServer (https://sampleserver6.arcgisonline.com/arcgis/rest/services/USA/MapServer/2) has a layer "States". The Rest point shows me this layer and what each field within that layer is, but that's it. I want to get a list of areas, which is one of the fields of the "States" layer. How can I do this?

1 Answer 1

0

Too long for comments...

to list the field names:

https://sampleserver6.arcgisonline.com/arcgis/rest/services/USA/MapServer/2/query?where=1%3D1&text=&objectIds=&time=&geometry=&geometryType=esriGeometryEnvelope&inSR=&spatialRel=esriSpatialRelIntersects&relationParam=&outFields=state_name&returnGeometry=false&returnTrueCurves=false&maxAllowableOffset=&geometryPrecision=&outSR=&having=&returnIdsOnly=false&returnCountOnly=false&orderByFields=state_name&groupByFieldsForStatistics=&outStatistics=&returnZ=false&returnM=false&gdbVersion=&historicMoment=&returnDistinctValues=false&resultOffset=&resultRecordCount=&queryByDistance=&returnExtentOnly=false&datumTransformation=&parameterValues=&rangeValues=&quantizationParameters=&featureEncoding=esriDefault&f=pjson

returns

 "displayFieldName": "state_name",
 "fieldAliases": {
  "state_name": "STATE_NAME"
 },
 "fields": [
  {
   "name": "state_name",
   "type": "esriFieldTypeString",
   "alias": "STATE_NAME",
   "length": 25
  }
 ],
 "features": [
  {
   "attributes": {
    "state_name": "Alabama"
   }
  },
  {
   "attributes": {
    "state_name": "Alaska"
   }
  },
  {
   "attributes": {
    "state_name": "Arizona"
   }
  },
  {
   "attributes": {
    "state_name": "Arkansas"
   }
  },
  {
   "attributes": {
    "state_name": "California"
   }
  },
  {
   "attributes": {
    "state_name": "Colorado"
   }
  },
  {
   "attributes": {
    "state_name": "Connecticut"
   }
  },
  {
   "attributes": {
    "state_name": "Delaware"
   }
  },
  {
   "attributes": {
    "state_name": "District of Columbia"
   }
  },
  {
   "attributes": {
    "state_name": "Florida"
   }
  },
  {
   "attributes": {
    "state_name": "Georgia"
   }
  },
  {
   "attributes": {
    "state_name": "Hawaii"
   }
  },
  {
   "attributes": {
    "state_name": "Idaho"
   }
  },
  {
   "attributes": {
    "state_name": "Illinois"
   }
  },
  {
   "attributes": {
    "state_name": "Indiana"
   }
  },
  {
   "attributes": {
    "state_name": "Iowa"
   }
  },
  {
   "attributes": {
    "state_name": "Kansas"
   }
  },
  {
   "attributes": {
    "state_name": "Kentucky"
   }
  },
  {
   "attributes": {
    "state_name": "Louisiana"
   }
  },
  {
   "attributes": {
    "state_name": "Maine"
   }
  },
  {
   "attributes": {
    "state_name": "Maryland"
   }
  },
  {
   "attributes": {
    "state_name": "Massachusetts"
   }
  },
  {
   "attributes": {
    "state_name": "Michigan"
   }
  },
  {
   "attributes": {
    "state_name": "Minnesota"
   }
  },
  {
   "attributes": {
    "state_name": "Mississippi"
   }
  },
  {
   "attributes": {
    "state_name": "Missouri"
   }
  },
  {
   "attributes": {
    "state_name": "Montana"
   }
  },
  {
   "attributes": {
    "state_name": "Nebraska"
   }
  },
  {
   "attributes": {
    "state_name": "Nevada"
   }
  },
  {
   "attributes": {
    "state_name": "New Hampshire"
   }
  },
  {
   "attributes": {
    "state_name": "New Jersey"
   }
  },
  {
   "attributes": {
    "state_name": "New Mexico"
   }
  },
  {
   "attributes": {
    "state_name": "New York"
   }
  },
  {
   "attributes": {
    "state_name": "North Carolina"
   }
  },
  {
   "attributes": {
    "state_name": "North Dakota"
   }
  },
  {
   "attributes": {
    "state_name": "Ohio"
   }
  },
  {
   "attributes": {
    "state_name": "Oklahoma"
   }
  },
  {
   "attributes": {
    "state_name": "Oregon"
   }
  },
  {
   "attributes": {
    "state_name": "Pennsylvania"
   }
  },
  {
   "attributes": {
    "state_name": "Rhode Island"
   }
  },
  {
   "attributes": {
    "state_name": "South Carolina"
   }
  },
  {
   "attributes": {
    "state_name": "South Dakota"
   }
  },
  {
   "attributes": {
    "state_name": "Tennessee"
   }
  },
  {
   "attributes": {
    "state_name": "Texas"
   }
  },
  {
   "attributes": {
    "state_name": "Utah"
   }
  },
  {
   "attributes": {
    "state_name": "Vermont"
   }
  },
  {
   "attributes": {
    "state_name": "Virginia"
   }
  },
  {
   "attributes": {
    "state_name": "Washington"
   }
  },
  {
   "attributes": {
    "state_name": "West Virginia"
   }
  },
  {
   "attributes": {
    "state_name": "Wisconsin"
   }
  },
  {
   "attributes": {
    "state_name": "Wyoming"
   }
  }
 ]
}
2
  • Is there a way to get that data through arcpy (or python in general)? For this example, the end result that I need is a python list of the states. Commented Jun 21, 2022 at 15:29
  • yes there is lots of examples online. developers.arcgis.com/python
    – Mapperz
    Commented Jun 21, 2022 at 18:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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