Querying a map service with the ArcGIS REST API and Python

The query operation in the ArcGIS REST API performs a query against a map service and returns a feature set. The feature set includes values for fields requested by the user and can also return geometry, if requested.

Getting ready

In this recipe, you will build on the first recipe, in which you generated a URL using the ArcGIS Services page dialog box to generate results. In this recipe, you will use the ArcGIS Server Services page dialog box to generate a URL request that queried a map service layer and returned results. You may recall that the URL was http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer/1/query?text=&geometry=&geometryType=esriGeometryPolygon&inSR=&spatialRel=esriSpatialRelIntersects&relationParam=&objectIds=&where=STATE_FIPS+%3D+%2748%27+and+CNTY_FIPS+%3D+%27021%27&time=&returnCountOnly=false&returnIdsOnly=false&returnGeometry=false&maxAllowableOffset=&outSR=&outFields=POP2000%2CPOP2007%2CBLKGRP&f=pjson ...

Get Programming ArcGIS with Python Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.