Book Image

Programming ArcGIS with Python Cookbook, Second Edition

By : Donald Eric Pimpler, Eric Pimpler
Book Image

Programming ArcGIS with Python Cookbook, Second Edition

By: Donald Eric Pimpler, Eric Pimpler

Overview of this book

Table of Contents (22 chapters)
Programming ArcGIS with Python Cookbook Second Edition
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

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…

  1. In your Python development environment, create a new script, save it as C:\ArcpyBook\Ch12\ExportMapToImage.py.

  2. Import the requests and json modules:

    import requests
    import json
  3. 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...