Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
ArcGIS Blueprints
ArcGIS Blueprints

ArcGIS Blueprints: Explore the robust features of Python to create real-world ArcGIS applications through exciting, hands-on projects

eBook
€24.99 €36.99
Paperback
€45.99
Subscription
Free Trial
Renews at $19.99p/m

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing
Table of content icon View table of contents Preview book icon Preview Book

ArcGIS Blueprints

Chapter 2. Tracking Elk Migration Patterns with GPS and ArcPy

In this chapter, we're going to build an application that imports a CSV file containing Global Positioning System (GPS) locations that depict elk migration patterns into a feature class that will be time-enabled to display migration patterns over time and space. We'll use the ArcPy data access (arcpy.da) module and the Python csv module to read the file containing GPS locations, and write the data to a new feature class. Next, we'll use the ArcPy mapping (archy.mapping) module to make the output feature class time-enabled, and then visualize the migration patterns of the elk over time and space. The application will be built as an ArcGIS Python Toolbox in much the same way as what we did in Chapter 1, Extracting Wildfire Data from an ArcGIS Server Map Service with the ArcGIS REST API.

In this chapter, we will cover the following topics:

  • ArcGIS Desktop Python toolboxes
  • Reading CSV files with the Python csv...

Design

Let's spend a little time going over the design of what we're going to build in this chapter. This application, like the one we built in the Chapter 1, Extracting Wildfire Data from an ArcGIS Server Map Service with the ArcGIS REST API, will include the creation of an ArcGIS Desktop Python Toolbox. The toolbox, MigrationPatterns.pyt, will include two tools: ImportCollarData and VisualizeMigration. The ImportCollarData tool will import GPS data from a collar that was attached to an elk in northern California. The GPS data will have been extracted to a comma-delimited text file (csv format), that will be read using the Python csv module and then imported into a local feature class stored in a file geodatabase using the arcpy.da which is a data access module. We'll then need to do a little manual work inside ArcMap. First, we'll make the feature class that was created as a result of the ImportCollarData tool time-enabled, and then we'll save the time-enabled...

Creating migration patterns for Python toolbox

Just like we did in the first chapter of the book, we'll build an ArcGIS Python Toolbox to hold the code for our application. I won't walk you through every single step like I did in the first chapter, but I will provide some general guidelines instead. If needed, refer to the first chapter for the specifics of how to create an ArcGIS Python Toolbox.

The Python toolboxes encapsulate everything in one place: parameters, validation code, and source code. A Python Toolbox functions like any other toolbox in ArcToolbox, but it is created entirely in Python and has a file extension of .pyt. As you learned in the last chapter, it is created programmatically as a class named Toolbox.

The following steps will help you to create migration patterns for Python toolbox:

  1. Open ArcCatalog. You can create a Python Toolbox in a folder by right-clicking on the folder and navigating to New | Python Toolbox. In ArcCatalog, there is a folder called Toolboxes...

Creating the Import Collar Data tool

The following steps will help you to create Import Collar Data tool:

  1. Right-click on MigrationPatterns.pyt and select Edit. This will open your development environment, as shown in the following screenshot. Your environment will vary depending upon the editor that you defined in Chapter 1, Extracting Real-Time Wildfire Data from ArcGIS Server with the ArcGIS REST API:
    Creating the Import Collar Data tool
  2. Remember that you will not be changing the name of the class, which is Toolbox. However, you will rename the Tool class to reflect the name of the tool you want to create.
  3. Find the class named Tool in your code and change the name of this tool to ImportCollarData, and set the label and description properties:
    class ImportCollarData(object):
        def __init__(self):
            """Define the tool (tool name is the name of the class)."""
            self.label = "Import Collar Data"
            self.description = "Import Elk Collar Data"
            self.canRunInBackground...

Reading data from the CSV file and writing to the feature class

The following steps will help you to read and write data from CSV file to a write to feature class:

  1. The main work of a tool is done inside the execute() method. This is where the geoprocessing of the tool takes place. The execute() method, as shown in the following code, can accept a number of arguments, including the tools self, parameters, and messages:
    def execute(self, parameters, messages):
          """The source code of the tool."""
          return
  2. To access the parameter values that are passed into the tool, you can use the valueAsText() method. Add the following code to access the parameter values that will be passed into your tool. Remember from a previous step that the first parameter will contain a reference to a CSV file that will be imported and the second parameter is the output feature class where the data will be written:
    def execute(self, parameters, messages):
        inputCSV = parameters...

Making the data frame and layer time-enabled

In this section, you will learn how to make a layer and data frame time-enabled. You will then add a tool to the Migration Patterns toolbox that cycles through the time range for the layer and exports a PDF map showing the movement of the elk over time and space:

  1. If necessary, open C:\ArcGIS_Blueprint_Python\ch2\ElkMigration.mxd in ArcMap.
  2. First, we'll symbolize the features so that we display them differently for wet and dry seasons. Right-click on the Betsy feature class and select Properties.
  3. Click on the Symbology tab and then define the symbology, as shown in the following screenshot:
    Making the data frame and layer time-enabled
  4. Now, select the Time tab, as shown in the following screenshot:
    Making the data frame and layer time-enabled
  5. Enable the time for the layer by clicking on the Enable time for this layer checkbox.
  6. Define Layer Time Extent by clicking on the Calculate button.
  7. Under Time properties, select Each feature has a single time field for Layer Time. Select the date field for Time Field. Define a Time Step Interval...

Design


Let's spend a little time going over the design of what we're going to build in this chapter. This application, like the one we built in the Chapter 1, Extracting Wildfire Data from an ArcGIS Server Map Service with the ArcGIS REST API, will include the creation of an ArcGIS Desktop Python Toolbox. The toolbox, MigrationPatterns.pyt, will include two tools: ImportCollarData and VisualizeMigration. The ImportCollarData tool will import GPS data from a collar that was attached to an elk in northern California. The GPS data will have been extracted to a comma-delimited text file (csv format), that will be read using the Python csv module and then imported into a local feature class stored in a file geodatabase using the arcpy.da which is a data access module. We'll then need to do a little manual work inside ArcMap. First, we'll make the feature class that was created as a result of the ImportCollarData tool time-enabled, and then we'll save the time-enabled data in a map document file...

Creating migration patterns for Python toolbox


Just like we did in the first chapter of the book, we'll build an ArcGIS Python Toolbox to hold the code for our application. I won't walk you through every single step like I did in the first chapter, but I will provide some general guidelines instead. If needed, refer to the first chapter for the specifics of how to create an ArcGIS Python Toolbox.

The Python toolboxes encapsulate everything in one place: parameters, validation code, and source code. A Python Toolbox functions like any other toolbox in ArcToolbox, but it is created entirely in Python and has a file extension of .pyt. As you learned in the last chapter, it is created programmatically as a class named Toolbox.

The following steps will help you to create migration patterns for Python toolbox:

  1. Open ArcCatalog. You can create a Python Toolbox in a folder by right-clicking on the folder and navigating to New | Python Toolbox. In ArcCatalog, there is a folder called Toolboxes; inside...

Left arrow icon Right arrow icon

Key benefits

  • Get to grips with the big world of Python add-ins and wxPython in GUI development to implement their features in your application
  • Integrate advanced Python libraries, ArcPy mapping, and data access module techniques to develop a mapping application
  • Construct a top-notch intermediate-to-advanced project by accessing ArcGIS Server and ArcGIS Online resources through the ArcGIS REST API using a project-based approach

Description

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.

Who is this book for?

If you have prior experience building simple apps with ArcGIS and now have a fancy for developing a more challenging and complex desktop application in ArcGIS, then this book is ideal for you.

What you will learn

  • Automate the creation of creative output data visualizations including maps, charts, and graphs
  • Explore ways to use the ArcPy Mapping module and Data-driven Pages to automate the creation of map books in your own project
  • Develop applications that use the Plotly platform and library to create stunning charts and graphs that can be integrated into ArcGIS Desktop
  • Build tools that access REST services and download data to a local geodatabase Design, build, and integrate advanced GUIs with wxPython and ArcGIS Desktop in ArcGIS
  • Get clued up about constructing applications that export data to Google Earth Pro to automate time-consuming complex processes
  • Maximize the access of ArcGIS Server and ArcGIS Online using the ArcGIS REST API with Python

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Dec 22, 2015
Length: 378 pages
Edition : 1st
Language : English
ISBN-13 : 9781785286223
Vendor :
ESRI
Category :
Languages :
Tools :

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing

Product Details

Publication date : Dec 22, 2015
Length: 378 pages
Edition : 1st
Language : English
ISBN-13 : 9781785286223
Vendor :
ESRI
Category :
Languages :
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
$19.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
$199.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts
$279.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total 124.97
Programming ArcGIS with Python Cookbook, Second Edition
€36.99
ArcGIS Blueprints
€45.99
Learning Geospatial Analysis with Python-Second Edition
€41.99
Total 124.97 Stars icon

Table of Contents

12 Chapters
1. Extracting Real-Time Wildfire Data from ArcGIS Server with the ArcGIS REST API Chevron down icon Chevron up icon
2. Tracking Elk Migration Patterns with GPS and ArcPy Chevron down icon Chevron up icon
3. Automating the Production of Map Books with Data Driven Pages and ArcPy Chevron down icon Chevron up icon
4. Analyzing Crime Patterns with ArcGIS Desktop, ArcPy, and Plotly(Part 1) Chevron down icon Chevron up icon
5. Analyzing Crime Patterns with ArcGIS Desktop, ArcPy, and Plotly(Part 2) Chevron down icon Chevron up icon
6. Viewing and Querying Parcel Data Chevron down icon Chevron up icon
7. Using Python with the ArcGIS REST API and the GeoEnrichment Service for Retail Site Selection Chevron down icon Chevron up icon
8. Supporting Search and Rescue Operations with ArcPy, Python Add-Ins, and simplekml Chevron down icon Chevron up icon
9. Real-Time Twitter Mapping with Tweepy, ArcPy, and the Twitter API Chevron down icon Chevron up icon
10. Integrating Smartphone Photos with ArcGIS Desktop and ArcGIS Online Chevron down icon Chevron up icon
A. Overview of Python Libraries for ArcGIS Chevron down icon Chevron up icon
Index Chevron down icon Chevron up icon

Customer reviews

Rating distribution
Full star icon Full star icon Full star icon Full star icon Empty star icon 4
(1 Ratings)
5 star 0%
4 star 100%
3 star 0%
2 star 0%
1 star 0%
Amazon Customer Mar 11, 2017
Full star icon Full star icon Full star icon Full star icon Empty star icon 4
A great resource that focuses on creating add-ins and Python toolboxes in ArcMap. A great bonus are a set of freely available Python packages that can be used to extend ArcMap so that you can interact with the ArcGIS REST API, among others. For intermediate and advanced arcpy users.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

What is included in a Packt subscription? Chevron down icon Chevron up icon

A subscription provides you with full access to view all Packt and licnesed content online, this includes exclusive access to Early Access titles. Depending on the tier chosen you can also earn credits and discounts to use for owning content

How can I cancel my subscription? Chevron down icon Chevron up icon

To cancel your subscription with us simply go to the account page - found in the top right of the page or at https://subscription.packtpub.com/my-account/subscription - From here you will see the ‘cancel subscription’ button in the grey box with your subscription information in.

What are credits? Chevron down icon Chevron up icon

Credits can be earned from reading 40 section of any title within the payment cycle - a month starting from the day of subscription payment. You also earn a Credit every month if you subscribe to our annual or 18 month plans. Credits can be used to buy books DRM free, the same way that you would pay for a book. Your credits can be found in the subscription homepage - subscription.packtpub.com - clicking on ‘the my’ library dropdown and selecting ‘credits’.

What happens if an Early Access Course is cancelled? Chevron down icon Chevron up icon

Projects are rarely cancelled, but sometimes it's unavoidable. If an Early Access course is cancelled or excessively delayed, you can exchange your purchase for another course. For further details, please contact us here.

Where can I send feedback about an Early Access title? Chevron down icon Chevron up icon

If you have any feedback about the product you're reading, or Early Access in general, then please fill out a contact form here and we'll make sure the feedback gets to the right team. 

Can I download the code files for Early Access titles? Chevron down icon Chevron up icon

We try to ensure that all books in Early Access have code available to use, download, and fork on GitHub. This helps us be more agile in the development of the book, and helps keep the often changing code base of new versions and new technologies as up to date as possible. Unfortunately, however, there will be rare cases when it is not possible for us to have downloadable code samples available until publication.

When we publish the book, the code files will also be available to download from the Packt website.

How accurate is the publication date? Chevron down icon Chevron up icon

The publication date is as accurate as we can be at any point in the project. Unfortunately, delays can happen. Often those delays are out of our control, such as changes to the technology code base or delays in the tech release. We do our best to give you an accurate estimate of the publication date at any given time, and as more chapters are delivered, the more accurate the delivery date will become.

How will I know when new chapters are ready? Chevron down icon Chevron up icon

We'll let you know every time there has been an update to a course that you've bought in Early Access. You'll get an email to let you know there has been a new chapter, or a change to a previous chapter. The new chapters are automatically added to your account, so you can also check back there any time you're ready and download or read them online.

I am a Packt subscriber, do I get Early Access? Chevron down icon Chevron up icon

Yes, all Early Access content is fully available through your subscription. You will need to have a paid for or active trial subscription in order to access all titles.

How is Early Access delivered? Chevron down icon Chevron up icon

Early Access is currently only available as a PDF or through our online reader. As we make changes or add new chapters, the files in your Packt account will be updated so you can download them again or view them online immediately.

How do I buy Early Access content? Chevron down icon Chevron up icon

Early Access is a way of us getting our content to you quicker, but the method of buying the Early Access course is still the same. Just find the course you want to buy, go through the check-out steps, and you’ll get a confirmation email from us with information and a link to the relevant Early Access courses.

What is Early Access? Chevron down icon Chevron up icon

Keeping up to date with the latest technology is difficult; new versions, new frameworks, new techniques. This feature gives you a head-start to our content, as it's being created. With Early Access you'll receive each chapter as it's written, and get regular updates throughout the product's development, as well as the final course as soon as it's ready.We created Early Access as a means of giving you the information you need, as soon as it's available. As we go through the process of developing a course, 99% of it can be ready but we can't publish until that last 1% falls in to place. Early Access helps to unlock the potential of our content early, to help you start your learning when you need it most. You not only get access to every chapter as it's delivered, edited, and updated, but you'll also get the finalized, DRM-free product to download in any format you want when it's published. As a member of Packt, you'll also be eligible for our exclusive offers, including a free course every day, and discounts on new and popular titles.