ArcGIS – Extracting Data from REST Endpoint

arcgis-onlinearcgis-rest-apigeojsonjson

I am trying to export the data in GeoJSON or JSON format from this REST service. I keep getting an error from the request.

http://maps3.arcgisonline.com/ArcGIS/rest/services/A-16/FEMA_100-Year_Flood_Zones_in_the_USA/MapServer/1

I need the geometry and attributes returned.

I am using this page to try and query for all of the data.

http://maps3.arcgisonline.com/ArcGIS/rest/services/A-16/FEMA_100-Year_Flood_Zones_in_the_USA/MapServer/1/query

I choose the format as JSON and in the Return Fields (Comma Separated): I enter "*"

What else do I need to enter into the QUERY to return this layer?


I entered objectid is not null into the where clause and it returned the cryptic Esri rings format

http://maps3.arcgisonline.com/ArcGIS/rest/services/A-16/FEMA_100-Year_Flood_Zones_in_the_USA/MapServer/1/query?text=&geometry=&geometryType=esriGeometryPoint&inSR=&spatialRel=esriSpatialRelIntersects&relationParam=&objectIds=&where=objectid+is+not+null&time=&returnIdsOnly=false&returnGeometry=true&maxAllowableOffset=&outSR=&outFields=%22*%22&f=pjson

Best Answer

You need to make a request to the ?query endpoint of the layer, and supply a where clause. Specify &f=json to receive the response in JSON.

Note that ArcGIS Server by default only returns the first 1000 records, so you may need to batch your requests using OBJECTID ranges as the where clause until you've retrieved all records, using this syntax:

http://maps3.arcgisonline.com/ArcGIS/rest/services/A-16/FEMA_100-Year_Flood_Zones_in_the_USA/MapServer/1/query?&where=objectid%3E=1000+and+objectid%3C1999&f=json

That is, use where objectid < 999 in the first request, then where objectid >= 1000 and objectid < 1999, etc, until there are no more responses.

See Converting ArcGIS Server JSON to GeoJSON to convert this JSON response to GeoJSON

Related Question