Exporting a map with the ArcGIS REST API and Python
The ArcGIS REST API has a large set of operations that you can use when requesting information from an ArcGIS Server instance. For example, you can export maps, query layers, geocode addresses, and much more. In this recipe, you will learn how to export a map image from a map service.
Getting ready
The export
operation can be used to create a map image from a map service. The response to this request includes the URL of the image, width, height, extent, and scale. In this recipe, you'll use the export operation to export a map as an image file.
How to do it…
In your Python development environment, create a new script, save it as
C:\ArcpyBook\Ch12\ExportMapToImage.py
.Import the
requests
andjson
modules:import requests import json
Create a new variable called
agisurl
, assign the URL, and export the operation, as seen here:import requests import json agisurl = "http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Specialty/ESRI_StateCityHighway_USA...