ArcPy and ArcGIS – Geospatial Analysis with Python
eBook - ePub

ArcPy and ArcGIS – Geospatial Analysis with Python

Silas Toms

Share book
  1. 224 pages
  2. English
  3. ePUB (mobile friendly)
  4. Available on iOS & Android
eBook - ePub

ArcPy and ArcGIS – Geospatial Analysis with Python

Silas Toms

Book details
Book preview
Table of contents
Citations

About This Book

About This Book

  • Perform GIS analysis faster by automating tasks, such as selecting data or buffering data, by accessing GIS tools using scripting
  • Access the spatial data contained within shapefiles and geodatabases, for updates, analysis and even transformation between spatial reference systems
  • Produce map books and automate the mapping of geospatial analyses, reducing the time needed to produce and display the results

Who This Book Is For

If you are a GIS student or professional who needs an understanding of how to use ArcPy to reduce repetitive tasks and perform analysis faster, this book is for you. It is also a valuable book for Python programmers who want to understand how to automate geospatial analyses.

Frequently asked questions

How do I cancel my subscription?
Simply head over to the account section in settings and click on “Cancel Subscription” - it’s as simple as that. After you cancel, your membership will stay active for the remainder of the time you’ve paid for. Learn more here.
Can/how do I download books?
At the moment all of our mobile-responsive ePub books are available to download via the app. Most of our PDFs are also available to download and we're working on making the final remaining ones downloadable now. Learn more here.
What is the difference between the pricing plans?
Both plans give you full access to the library and all of Perlego’s features. The only differences are the price and subscription period: With the annual plan you’ll save around 30% compared to 12 months on the monthly plan.
What is Perlego?
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 1000+ topics, we’ve got you covered! Learn more here.
Do you support text-to-speech?
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more here.
Is ArcPy and ArcGIS – Geospatial Analysis with Python an online PDF/ePUB?
Yes, you can access ArcPy and ArcGIS – Geospatial Analysis with Python by Silas Toms in PDF and/or ePUB format, as well as other popular books in Ciencia de la computación & Servicios web y API. We have over one million books available in our catalogue for you to explore.

Information

ArcPy and ArcGIS – Geospatial Analysis with Python


Table of Contents

ArcPy and ArcGIS – Geospatial Analysis with Python
Credits
About the Author
About the Reviewers
www.PacktPub.com
Support files, eBooks, discount offers, and more
Why subscribe?
Free access for Packt account holders
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Downloading the color images of this book
Errata
Piracy
Questions
1. Introduction to Python for ArcGIS
Overview of Python
Python as a programming language
Interpreted language
Standard (built-in) library
The glue language
Wrapper modules
The basics of Python
Import statements
Variables
For loops
If/Elif/Else statements
While statements
Comments
Data types
Strings
Integers
Floats
Lists
Tuples
Dictionaries
Iterable data types
Other important concepts
Indentation
Functions
Keywords
Namespaces
Zero-based indexing
Important Python Modules for GIS Analysis
The ArcPy module
The Operating System (OS) module
The Python System (SYS) module
The XLRD and XLWT modules
Commonly used built-in functions
Commonly used standard library modules
Summary
2. Configuring the Python Environment
What is a Python script?
How Python executes a script
What is the Python interpreter?
Where is the Python interpreter located?
Which Python interpreter should be used?
How does the computer know where the interpreter is?
Make Python scripts executable when clicked on
Integrated Development Environments (IDEs)
IDLE
PythonWin
Aptana Studio 3
IDE summary
Python folder structure
Where modules reside
Using Python's sys module to add a module
The sys.path.append() method
Summary
3. Creating the First Python Script
Prerequisites
ModelBuilder
Creating a model and exporting to Python
Modeling the Select and Buffer tools
Adding the Intersect tool
Tallying the analysis results
Exporting the model and adjusting the script
The automatically generated script
File paths in Python
Continuing the script analysis: the ArcPy tools
The Intersect tool and string manipulation
The string manipulation method 1–string addition
The string manipulation method 2–string formatting #1
The string manipulation method 3–string formatting #2
Adjusting the Script
Adding the CSV module to the script
Accessing the data: Using a cursor
The final script
Summary
4. Complex ArcPy Scripts and Generalizing Functions
Python functions–Avoid repeating code
Technical definition of functions
A first function
Functions with parameters
Using functions to replace repetitive code
More generalization of the functions
Summary
5. ArcPy Cursors – Search, Insert, and Update
The data access module
Attribute field interactions
Update cursors
Updating the shape field
Adjusting a point location
Deleting a row using an Update Cursor
Using an Insert Cursor
Inserting a polyline geometry
Inserting a polygon geometry
Summary
6. Working with ArcPy Geometry Objects
ArcPy geometry object classes
ArcPy Point objects
ArcPy Array objects
ArcPy Polyline objects
ArcPy Polygon objects
Polygon object buffers
Other Polygon object methods
ArcPy geometry objects
ArcPy PointGeometry objects
Summary
7. Creating a Script Tool
Adding dynamic parameters to a script
Displaying script messages using arcpy.AddMessage
Adding dynamic components to the script
Creating a Script tool
Labelling and defining parameters
Adding data types
Adding the Bus Stop feature class as a parameter
Adding the Census Block feature class as a parameter
Adding the Census Block field as a parameter
Adding the output spreadsheet as a parameter
Adding the spreadsheet field names as a parameter
Adding the SQL Statement as a parameter
Adding the bus stop fields as a parameter
Inspecting the final script
Running the Script Tool
Summary
8. Introduction to ArcPy.Mapping
Using ArcPy with map documents
Inspecting and replacing layer sources
Fixing the broken links
Fixing the links of individual layers
Exporting to PDF from an MXD
Adjusting map document elements
Automated map document adjustment
The variables
The map document object and the text elements
The layer objects
Replacing the data sources
Adjusting layer visibility
Generating a buffer from the bus stops feature class
Intersecting the bus stop buffer and census blocks
Populating the selected bus stop and buffer feature classes
Updating the text elements
Exporting the adjusted map to PDF
Running the script in the Python Window
Summary
9. More ArcPy.Mapping Techniques
Using arcpy.mapping to control Layer objects
Layer object methods and properties
Definition queries
Controlling the data frame window extent and scale
Adding a Layer object
Exporting the maps
Summary
10. Advanced Geometry Object Methods
Creating a Python module
The __init__.py file
Adding advanced analysis components
Advanced Polygon object methods
Generating random points to represent population
Using the functions within a script
Creating an XLS using XLWT
Summary
11. Network Analyst and Spatial Analyst with ArcPy
The Network Analyst extension
Using Network Analyst
Creating a Feature Dataset
Importing the datasets
Creating the Network Dataset
Accessing the Network Dataset using ArcPy
Breaking down the script
The Network Analyst module
Accessing the Spatial Analyst Extension
Adding elevation to the bus stops
Using Map Algebra to generate elevation in feet
Adding in the bus stops and getting elevation values
The final result
Summary
12. The End of the Beginning
Getting field information from feature classes
Accessing the ListFields' properties
List comprehensions
Creating the field information functions
Querying feature class information
Generating File Geodatabases and feature classes
Generating a feature class
Setting up the script tool parameters
Environmental settings
Resolution and tolerance settings
Summary
Index

ArcP...

Table of contents