44,39 €
This book is an immersive guide to take your ArcGIS Desktop application development skills to the next level
It starts off by providing detailed description and examples of how to create ArcGIS Desktop Python toolboxes that will serve as containers for many of the applications that you will build. We provide several practical projects that involve building a local area/community map and extracting wildfire data. You will then learn how to build tools that can access data from ArcGIS Server using the ArcGIS REST API. Furthermore, we deal with the integration of additional open source Python libraries into your applications, which will help you chart and graph advanced GUI development; read and write JSON, CSV, and XML format data sources; write outputs to Google Earth Pro, and more. Along the way, you will be introduced to advanced ArcPy Mapping and ArcPy Data Access module techniques and use data-driven Pages to automate the creation of map books.
Finally, you will learn advanced techniques to work with video and social media feeds. By the end of the book, you will have your own desktop application without having spent too much time learning sophisticated theory.
Das E-Book können Sie in Legimi-Apps oder einer beliebigen App lesen, die das folgende Format unterstützen:
Seitenzahl: 290
Veröffentlichungsjahr: 2015
Copyright © 2015 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
First published: December 2015
Production reference: 1151215
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham B3 2PB, UK.
ISBN 978-1-78528-622-3
www.packtpub.com
Author
Eric Pimpler
Reviewers
Chad Cooper
Eleza Boban Kollannur
Prasad Lingam
Shaik Shavali
Commissioning Editor
Akram Hussain
Acquisition Editor
Vinay Argekar
Content Development Editor
Siddhesh Salvi
Technical Editor
Vishal Mewada
Copy Editor
Stuti Srivastava
Project Coordinator
Nidhi Joshi
Proofreader
Safis Editing
Indexer
Priya Sane
Graphics
Kirk D'Penha
Production Coordinator
Shantanu N. Zagade
Cover Work
Shantanu N. Zagade
Eric Pimpler is the founder and owner of GeoSpatial Training Services (http://geospatialtraining.com/) and has over 20 years of experience implementing and teaching GIS solutions using Esri, Google Earth, Google Maps, and open source technologies. Currently, he focuses on ArcGIS application development with Python and the development of custom ArcGIS Server web and mobile applications using JavaScript.
Eric is the author of Programming ArcGIS 10.1 with Python Cookbook, Programming ArcGIS with Python Cookbook - Second Edition, Building Web and Mobile ArcGIS Server Applications with JavaScript, and the soon to be published ArcGIS Blueprints.
He has a bachelor's degree in geography from Texas A&M University and a master of applied geography degree with a concentration in GIS from Texas State University.
Chad Cooper has worked in the geographic information systems realm for 13 years in technician, analyst, and developer roles. He is currently a solutions engineer with Geographic Information Services, Inc. (http://www.gisinc.com/), where he works on a variety of projects for the state and local government teams. Chad has been published in Esri's ArcUser magazine and the Python magazine. He lives in northwest Arkansas with his beautiful wife and three children.
Eleza Boban Kollannur is an architect and environmental planner working as a GIS analyst in the water and waste water sector for more than 6 years. She is passionate about the development of automation and programming solutions through model building and Python scripting. She has been involved in master planning and coastal and marine projects for the preparation of a water balance model, watershed analysis, network model builds, and spatial analysis. She has worked with MWH Global and DHI India for various projects in the Middle East, India, and UK. Eleza is interested in building custom user interface (UI) geoprocessing tools for ArcGIS desktop and server with Python.
Prasad Lingam has been passionately exploring geoinformation technologies for almost 10 years. He has gained knowledge in the application of geoinformatics to areas such as urban planning, transportation, utilities, environment, and construction management, thus leveraging his civil engineering background. He is currently working at MWH (for more information, visit http://www.mwhglobal.com/) in the water and waste water domain, implementing geospatial analysis in Desktop GIS and promoting web- and mobile-based GIS Applications to solve operational and planning issues. His work experience spans project locations such as Perth, Middle East, New Zealand, Fiji, and India. He is keen about studying the confluence of geospatial technologies with technologies such as big data, BIM, geovisualization, and so on.
Shaik Shavali is a senior GIS developer at Dar Al-Riyadh. He has 7 years of experience in the field of geospatial technologies and projects. His areas of expertises are developing custom GIS web and mobile applications using the latest ESRI technologies. He was one of the lead developers for Emergency Response Management Systems for the largest Islamic pilgrimage (Hajj), gathering nearly 2 million people. Currently, he is actively taking part in designing and developing GIS projects for the government sector in Saudi Arabia.
He has received his bachelor's in engineering degree, and presently, he is pursuing his master's in GIS through UNIGIS.
Firstly, I would like to thank Allah for his countless blessings. I would also like to thank my parents (Akbar Saheb and Fathima), in-laws (Ehasanulla and Shahnaz), and family for their emotional support, guidance, and prayers. Finally, I would like to thank my better-half, Farheen Ehasanulla, for her love and support, which always pushed me to do better. She is my backbone, best critic, and most importantly, my best friend.
For support files and downloads related to your book, please visit www.PacktPub.com.
Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at <[email protected]> for more details.
At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks.
https://www2.packtpub.com/books/subscription/packtlib
Do you need instant solutions to your IT questions? PacktLib is Packt's online digital book library. Here, you can search, access, and read Packt's entire library of books.
If you have an account with Packt at www.PacktPub.com, you can use this to access PacktLib today and view 9 entirely free books. Simply use your login credentials for immediate access.
ArcGIS Desktop 10.3 is the leading desktop solution for GIS analysis and mapping. The ArcPy site package, which contains the ArcPy mapping and Data Access modules, enables Python programmers to access all the GIS functionalities provided through ArcGIS Desktop. ArcPy can be integrated with other open source Python libraries to enhance GUI development; create stunning reports, charts, and graphs; access REST web services; perform statistics analysis; and more. This book will teach you how to take your ArcGIS Desktop application development skills to the next level by integrating the functionality provided by ArcPy with open source Python libraries to create advanced ArcGIS Desktop applications.
In addition to working with the ArcPy, ArcPy Mapping, and ArcPy Data Access modules, the book also covers the ArcGIS REST API and a wide variety of open source Python modules, including requests, csv, plotly, tweepy, simplekml, wxPython, and others.
Chapter 1, Extracting Real-Time Wildfire Data from ArcGIS Server with the ArcGIS REST API, describes how to use the ArcGIS REST API with Python to extract real-time wildfire information from an ArcGIS Server map service and write the data to a local geodatabase. A Python Toolbox will be created in ArcGIS Desktop to hold the tools.
Chapter 2, Tracking Elk Migration Patterns with GPS and ArcPy, teaches you how to read a CSV file containing the GPS coordinates of elk migration patterns and write the data to a local geodatabase. The ArcPy mapping module will then be used to visualize time-enabled data and create a series of maps that show the migration patterns over time.
Chapter 3, Automating the Production of Map Books with Data Driven Pages and ArcPy, shows you how to use the Data Driven Pages functionality in ArcGIS Desktop along with the ArcPy mapping module to automate the production of a map book. The use of Python add-ins for ArcGIS Desktop for user interface development will also be introduced.
Chapter 4, Analyzing Crime Patterns with ArcGIS Desktop, ArcPy, and Plotly - Part 1, is the first of two chapters that covers the creation of ArcPy scripts for crime analysis. In this first chapter, you'll learn how to use the Python requests module to extract crime data from the city of Seattle's open database and write to a local geodatabase. You'll then write custom script tools to aggregate the crime data at various geographic levels and create maps that can be printed or exported to a PDF format.
Chapter 5, Analyzing Crime Patterns with ArcGIS Desktop, ArcPy, and Plotly - Part 2, is the second of two chapters that covers the creation of ArcPy scripts for crime analysis. In this chapter, you'll learn how to use the Plotly platform and the Python module to create compelling graphs and charts of crime data that can be integrated into the ArcGIS Desktop layout view for printing and export.
Chapter 6, Viewing and Querying Parcel Data, teaches you how to use the wxPython module to create advanced graphical user interface (GUI) applications for ArcGIS Desktop using Python within the context of an application that queries and views parcel data. Python add-ins for ArcGIS Desktop will also be used in the creation of the application.
Chapter 7, Using Python with the ArcGIS REST API and GeoEnrichment Service for Retail Site Selection, teaches you how to use the ArcGIS Online GeoEnrichment Service with Python to retrieve demographic and lifestyle information to support the site selection process of a new store location. You'll also build tools to interactively select the potential geographic location of stores based on demographic factors.
Chapter 8, Supporting Search and Rescue Operations with ArcPy, Python Add-Ins, and simplekml, teaches you how to build a Search and Rescue (SAR) application that identifies the last known location of the subject, creates search sectors in the support of operations, and exports the data to Google Earth for visualization purposes.
Chapter 9, Real Time Twitter Mapping with Tweepy, ArcPy, and the Twitter API, covers the mining of a live stream of tweets containing specific terms and hash tags. Tweets that contain geographic coordinates will be written to a local geodatabase for further analysis. In addition, several tools will be created to enable the analysis of this social media data. Finally, the results will be shared with the public through the ArcGIS Online service.
Chapter 10, Integrating Smart Phone Photos with ArcGIS Desktop and ArcGIS Online, covers the creation of a real estate application that reads photo metadata, extracts the coordinate information, retrieves the nearest address to the photo, and writes this information to a local feature class. In addition, the photos will be copied to a Dropbox account using the Python Dropbox module so that the photos can be accessed through a web application. Finally, the property feature class will be uploaded to ArcGIS Online, integrated with the Dropbox photos, and shared as a web-based map.
ArcGIS Blueprints is written for ArcGIS Desktop 10.3. However, ArcGIS Desktop 10.2 can be used for most of the chapters as well. Python 2.7, along with the IDLE development environment, is installed along with ArcGIS Desktop, so no additional installations of Python should be performed. If desired, you can use your preferred Python development environment. I recommend PyScripter if you don't have a preference.
ArcGIS Blueprints is written for intermediate-level ArcGIS Desktop programmers who wish to take their development skills to the next level. This book will cover intermediate to advanced level ArcGIS Desktop development topics with ArcPy and a variety of open source Python libraries to create applications for a wide array of topics.
Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or disliked. Reader feedback is important for us as it helps us develop titles that you will really get the most out of.
To send us general feedback, simply e-mail <[email protected]>, and mention the book's title in the subject of your message.
If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide at www.packtpub.com/authors.
Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.
You can download the example code files from your account at http://www.packtpub.com for all the Packt Publishing books you have purchased. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.
We also provide you with a PDF file that has color images of the screenshots/diagrams used in this book. The color images will help you better understand the changes in the output. You can download this file from https://www.packtpub.com/sites/default/files/downloads/ArcGISBlueprints_ColoredImages.pdf.
Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you could report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website or added to any list of existing errata under the Errata section of that title.
To view the previously submitted errata, go to https://www.packtpub.com/books/content/support and enter the name of the book in the search field. The required information will appear under the Errata section.
Piracy of copyrighted material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works in any form on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.
Please contact us at <[email protected]> with a link to the suspected pirated material.
We appreciate your help in protecting our authors and our ability to bring you valuable content.
If you have a problem with any aspect of this book, you can contact us at <[email protected]>, and we will do our best to address the problem.
The ArcGIS platform, which contains a number of different products, including ArcGIS Desktop, ArcGIS Pro, ArcGIS for Server, and ArcGIS Online, provides a robust environment to perform geographic analysis and mapping. The content produced by this platform can be integrated using the ArcGIS REST API and a programming language such as Python. Many of the applications we'll build in this book use the ArcGIS REST API as the bridge to exchange information between software products.
We're going to start by developing a simple ArcGIS Desktop custom script tool in ArcToolbox that connects to an ArcGIS Server map service to retrieve real-time wildfire information. The wildfire information will be retrieved from a USGS map service that provides real-time wildfire data. For this chapter and all other chapters in this book, the reader is expected to have intermediate-level experience of Python and ArcPy. Ideally, you should be running version 10.3 or 10.2 of ArcGIS Desktop. Previous versions of ArcGIS Desktop have some significant differences that may cause problems in the development of some applications in the book.
We'll use the ArcGIS REST API and the Python requests module to connect to the map service and request the data. The response from the map service will contain data that will be written to a feature class stored in a local geodatabase using the ArcPy data access module.
This will all be accomplished with a custom script tool attached to an ArcGIS Python Toolbox. ArcGIS Python toolboxes are relatively new; they were first introduced in version 10.1 of ArcGIS Desktop. They provide a Python-centric method to create custom toolboxes and tools. The older method to create toolboxes in ArcGIS Desktop, while still relevant, requires a combination of Python and a wizard-based approach to create tools.
In this chapter, we will cover the following topics:
A general overview of the Python libraries for ArcGIS is provided in the appendix of this book. It is recommended that you read this chapter before continuing with the appendix and other chapters.
Before we start building the application, we'll spend some time planning what we'll build. This is a fairly simple application, but it serves to illustrate how ArcGIS Desktop and ArcGIS Server can be easily integrated using the ArcGIS REST API. In this application, we'll build an ArcGIS Python Toolbox that serves as a container for a single tool called USGSDownload. The USGSDownload tool will use the Python requests, JavaScript Object Notation (JSON), and ArcPy da modules to request real-time wildfire data from a USGS map service. The response from the map service will contain information including the location of the fire, the name of the fire, and some additional information that will then be written to a local geodatabase.
The communication between the ArcGIS Desktop Python Toolbox and the ArcGIS Server map service will be accomplished through the ArcGIS REST API and the Python language.
Let's get started and build the application.
In the previous section, you learned how to create a Python Toolbox and add tools. You created a new toolbox called InsertWildfires and added a tool called USGS Download. However, in that exercise, you didn't complete the geoprocessing operations that connect to an ArcGIS Server map service, query the service for current wildfires, and populate the feature class from the data pulled from the map service query. You'll complete these steps in the following section.
This section of the application uses the Python requests module. If you don't already have this module installed on your computer, you will need to do this at this time using pip.
The pip is a package manager that serves as a repository and installation manager for Python modules. It makes finding and installing Python modules much easier. There are several steps that you'll need to follow in order to install pip and the requests module. Instructions to install pip and the requests module are provided in the first few steps:
