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

Index

A

  • active map document
    • accessing, in ArcMap / How to do it..., How it works...
  • add-in
    • about / Introduction
    • installing / Installing and testing an add-in, How to do it…, How it works…
    • testing / Getting ready, How to do it…, How it works…
  • AddFieldDelimiters() function / How it works…
  • AddLayer() function / Adding layers to a map document
  • ArcEditor
    • about / Getting ready
  • ArcGIS for Desktop
    • Python code, converting to ArcGIS Pro / Converting ArcGIS for Desktop Python code to ArcGIS Pro
  • ArcGIS Pro
    • about / Introduction
    • Python window, using / Using the new Python window in ArcGIS Pro
    • Python prompt section / Using the new Python window in ArcGIS Pro
    • Transcript section / Using the new Python window in ArcGIS Pro
    • and ArcGIS for Desktop, coding differences / Coding differences between ArcGIS for Desktop and ArcGIS Pro
    • Python, installing / Installing Python for ArcGIS Pro
    • ArcGIS for Desktop Python code, converting / Converting ArcGIS for Desktop Python code to ArcGIS Pro
  • ArcGIS Python window
    • using / Using the ArcGIS Python window
    • about / The ArcGIS Python window
    • displaying / Displaying the ArcGIS Python window
  • ArcGIS REST API
    • about / Getting started with the ArcGIS REST API
    • URL requests, constructing / Getting ready, How to do it…, How it works…
    • and Python, used for obtaining layer information / Getting layer information with the ArcGIS REST API and Python, How to do it…, How it works…
    • and Python, used for exporting map / Exporting a map with the ArcGIS REST API and Python, Getting ready, How to do it…, How it works…
    • and Python, used for querying map service / Querying a map service with the ArcGIS REST API and Python, How to do it…, How it works…
  • ArcGIS Server
    • about / Publishing a map document to an ArcGIS Server service
    • URL / Publishing a map document to an ArcGIS Server service
  • ArcGIS Server service
    • map document, publishing / Getting ready, How to do it…, How it works…
  • ArcInfo
    • about / Getting ready
  • ArcMap
    • active map document, accessing in / How to do it..., How it works...
  • arcpy.mapping module / Getting ready
    • about / Introduction
  • arcpy data access module
    • about / Introduction
  • ArcPy list functions
    • working with / Working with the ArcPy list functions, How to do it…
    • ListFeatureClasses() / Getting ready, How to do it…
    • ListTables() / There's more…
    • ListFields() / Getting ready, How it works…
  • arcpy mapping
    • used, for building map book / Building a map book with Data Driven Pages and ArcPy mapping, How to do it…, How it works…
  • ArcToolbox
    • about / Getting ready
  • ArcView
    • about / Getting ready
  • attribute query
    • about / Introduction
  • attribute query syntax
    • constructing / Constructing a proper attribute query syntax, Getting ready, How to do it…, How it works…
  • auto-arrange feature / How it works…

B

  • batch files
    • Python scripts, adding to / Adding Python scripts to batch files, There's more...
    • scheduling, to run at prescribed times / Scheduling batch files to run at prescribed times, How to do it..., How it works...
  • broken data sources
    • fixing, with MapDocument.findAndReplaceWorkspacePaths() method / Fixing broken data sources with MapDocument.findAndReplaceWorkspacePaths(), Getting ready, How to do it…, There's more…
    • fixing, with MapDocument.replaceWorkspaces() method / Fixing broken data sources with MapDocument.replaceWorkspaces(), How to do it…, How it works…
    • searching, in map documents / Finding broken data sources in all map documents in a folder, How to do it..., How it works...
  • Buffer tool
    • about / Getting ready, How it works...
  • built-in data types
    • about / Built-in data types
    • strings / Strings
    • numbers / Numbers
    • lists / Lists
    • tuples / Tuples
    • dictionaries / Dictionaries
  • button add-in
    • creating / Creating a button add-in and using the Python add-ins module, Getting ready, How to do it...

C

  • command-line input
    • sys.argv[ ], using from / Using sys.argv[ ] to capture command-line input, Getting ready, How to do it...
  • command line
    • Python scripts, running from / Running Python scripts from the command line, How to do it…, How it works…
  • current map document
    • referencing / Referencing the current map document, How to do it…
  • cursors
    • about / Introduction
    • navigating / Introduction
    • performance improvement, with geometry tokens / Improving cursor performance with geometry tokens, Getting ready, How to do it…, How it works…
  • custom geoprocessing tool
    • creating / Creating a custom geoprocessing tool, Getting ready, How to do it…, There's more...

D

  • data
    • reading, from delimited text file / Reading data from a delimited text file, How to do it…, How it works…
  • Data Driven Pages
    • used, for building map book / Building a map book with Data Driven Pages and ArcPy mapping, How to do it…, How it works…
    • about / Getting ready
  • data frame
    • time-enabled layers, working with / Working with time-enabled layers in a data frame, How to do it..., How it works…
  • DataFrame.zoomToSelectedFeatures property / Getting ready
  • DataFrameTime object
    • about / Getting ready, How it works…
  • data view
    • about / Getting ready
  • dBase File Format (DBF) / Getting ready
  • decision statements
    • if/elif/else statement / Decision support statements
    • about / Decision support statements
  • default Python error message
    • exploring / Exploring the default Python error message, How it works…
  • delimited text file
    • data, reading / Reading data from a delimited text file, How to do it…, How it works…
  • Describe() function
    • descriptive information, returning for feature class / Using the Describe() function to return descriptive information about a feature class, Getting ready, How to do it…, How it works…
    • descriptive information, returning for raster image / Using the Describe() function to return descriptive information about a raster image, How to do it…
  • dictionaries
    • about / Dictionaries
  • directories
    • navigating, with Walk() function / Using Walk() to navigate directories, How to do it…, How it works…
  • document object model (DOM)
    • about / How it works…
  • dynamic typing variable
    • about / Variables

E

  • e-mails
    • sending / Sending e-mails, How to do it…
  • edit session
    • rows, updating / Inserting and updating rows inside an edit session, Getting ready, How to do it…, How it works…
    • rows, inserting / Inserting and updating rows inside an edit session, Getting ready, How to do it…, How it works…
  • end of file (EOF) marker
    • about / File I/O
  • Environmental Systems Research Institute (Esri) / Getting ready
  • error message / Getting ready
  • Esri World Geocoding Service
    • used, for geocoding / Geocoding with the Esri World Geocoding Service, Getting ready, How to do it…, How it works…

F

  • feature class
    • features retrieving, SearchCursor used / Retrieving features from a feature class with SearchCursor, Getting ready, How it works…
    • geometry, reading / Reading geometry from a feature class, How to do it…
    • list of fields, obtaining in / How to do it…, How it works…
  • feature layers
    • creating / Creating feature layers and table views, Getting ready, How to do it…, There's more...
    • about / Getting ready
  • features
    • selecting, with Select Layer by Attribute tool / Selecting features and rows with the Select Layer by Attribute tool, Getting ready, How to do it…
  • Federal Information Processing Standard (FIPS)
    • about / How to do it…
  • FieldMap
    • using / Using FieldMap and FieldMappings, Getting ready, How to do it…, How it works…
  • FieldMappings
    • using / Using FieldMap and FieldMappings, Getting ready, How to do it…, How it works…
  • files
    • retrieving, from FTP server / Retrieving files from an FTP server, How to do it…, How it works…
  • FTP server
    • files, retrieving / Retrieving files from an FTP server, How to do it…, How it works…

G

  • Generate Random Points tool
    • about / Getting ready
  • geocoding
    • with Esri World Geocoding Service / Geocoding with the Esri World Geocoding Service, Getting ready, How to do it…, How it works…
  • geometry
    • reading, from feature class / Reading geometry from a feature class, How to do it…
  • geometry tokens
    • about / Improving cursor performance with geometry tokens
    • used, for improving cursor performance / Improving cursor performance with geometry tokens, Getting ready, How to do it…, How it works…
  • geoprocessing tools
    • finding / Finding geoprocessing tools, How to do it…, How it works…
    • executing, from script / Executing geoprocessing tools from a script, How it works…
    • organizing / There's more...
    • multivalue input, providing with ValueTable / Using a ValueTable to provide multivalue input to a tool, How to do it…, How it works…
    • URL / Introduction
  • GetMessages()
    • tool messages, retrieving with / Retrieving tool messages with GetMessages(), Getting ready, How it works…
  • globally unique identifier or GUID name / How it works…

H

  • HTTP requests
    • creating / Making HTTP requests and parsing the response with Python
  • HTTP response
    • parsing, with Python / Making HTTP requests and parsing the response with Python
    • parsing, with Python json module / Making HTTP requests and parsing the response with Python, How to do it…, How it works…

I

  • IDLE
    • about / Using IDLE for Python script development
  • IDLE, for Python script development
    • about / Using IDLE for Python script development
    • Python shell window / The Python shell window
    • Python script window / The Python script window
    • existing Python scripts, editing / Editing existing Python scripts
    • scripts, executing from IDLE / Executing scripts from IDLE
  • image file
    • map, exporting / Exporting a map to an image file, How to do it…
  • indexing / String manipulation
  • individual layer
    • fixing, with replaceDataSource() method / Fixing individual layer and table objects with replaceDataSource(), How to do it…, How it works…, There's more…
  • informational messages / Getting ready
  • InsertCursor
    • about / Introduction
    • used, for inserting rows / Inserting rows with InsertCursor, How to do it…, How it works…
  • InsertLayer() function / Inserting layers into a map document
  • instance / How it works…

L

  • layer files
    • broken data sources, searching / Getting ready, How to do it…, How it works…
  • layer information
    • obtaining, with ArcGIS REST API and Python / Getting layer information with the ArcGIS REST API and Python, How to do it…, How it works…
  • layer properties
    • updating / Updating layer properties, How to do it…
  • layers
    • adding, to map document / Adding layers to a map document, How to do it…, How it works…, There's more…
    • inserting, into map document / Inserting layers into a map document, How to do it…, How it works…
  • layer symbology
    • updating / Updating layer symbology, Getting ready, How to do it…, How it works…
  • layout elements
    • listing / Creating a list of layout elements, Getting ready, How it works…
    • unique name, assigning / Assigning a unique name to layout elements, How to do it…, How it works…, There's more…
    • restricting, ListLayoutElements() function used / Restricting the layout elements returned by ListLayoutElements(), How it works...
    • properties, updating / Updating the properties of layout elements, Getting ready, How to do it…, How it works...
  • layout view
    • about / Getting ready
  • ListBrokenDataSources() function / Introduction, There's more…
  • ListDataFrames() function / How it works…
  • ListFields() function / How it works…
  • ListLayers() function / How it works…
  • ListLayoutElements() function
    • used, for restricting layout elements returned / Restricting the layout elements returned by ListLayoutElements(), How it works...
  • list of fields
    • returning, in feature class / How to do it…, How it works…
  • list of layers
    • obtaining, in map document / Getting a list of layers in a map document, How to do it…, There's more…
    • restricting / Restricting the list of layers, How to do it…
  • lists
    • about / Lists
  • ListTables() function / There's more…
  • looping statements
    • about / Looping statements
    • for loops / Looping statements

M

  • map
    • printing, with PrintMap() function / Printing maps with PrintMap(), Getting ready, How it works...
    • exporting, to PDF file / Exporting a map to a PDF file, How to do it…, How it works…
    • exporting, to image file / Exporting a map to an image file, How to do it…
    • exporting, with ArcGIS REST API and Python / Exporting a map with the ArcGIS REST API and Python, Getting ready, How to do it…, How it works…
  • map book
    • building, with Data Driven Pages / Building a map book with Data Driven Pages and ArcPy mapping, How to do it…, How it works…
    • building, with arcpy mapping / Building a map book with Data Driven Pages and ArcPy mapping, How to do it…, How it works…
  • map document
    • broken data sources, searching / Getting ready, How to do it…, How it works…
    • publishing, to ArcGIS Server service / Getting ready, How to do it…, How it works…
  • MapDocument.findAndReplaceWorkspacePaths() method
    • used, for fixing broken data sources / Fixing broken data sources with MapDocument.findAndReplaceWorkspacePaths(), How to do it…, There's more…
  • MapDocument.replaceWorkspaces() method
    • used, for fixing broken data sources / Fixing broken data sources with MapDocument.replaceWorkspaces(), How to do it…, How it works…
  • MapDocument class / How it works…
  • map documents
    • referencing / Referencing map documents on a disk, How it works…
    • list of layers, obtaining / Getting a list of layers in a map document, How to do it…
    • layers, adding / Adding layers to a map document, How to do it…, How it works…, There's more…
    • layers, inserting / Inserting layers into a map document, How to do it…, How it works…
  • map documents, folder
    • broken data sources, searching / Finding broken data sources in all map documents in a folder, How to do it..., How it works...
  • map extent
    • changing / Changing the map extent, How to do it..., How it works...
  • map service
    • querying, with ArcGIS REST API and Python / Querying a map service with the ArcGIS REST API and Python, How to do it…, How it works…
  • multivalue input
    • providing, with ValueTable / Using a ValueTable to provide multivalue input to a tool, How to do it…, How it works…

N

  • National Interagency Fire Center Incident FTP site
    • about / Getting ready
    • URL / Getting ready
  • nodes
    • about / Getting ready
  • numbers
    • about / Numbers

O

  • object / How it works…
  • open() function
    • about / File I/O

P

  • PDF file
    • map, exporting / Exporting a map to a PDF file, How to do it…, How it works…
  • pip
    • URL, for installing / How to do it…, How to do it…
  • printers
    • listing / Getting a list of available printers, How to do it…
  • PrintMap() function
    • used, for printing map / Printing maps with PrintMap(), Getting ready, How it works...
  • property groups
    • about / Getting ready
  • Python
    • and ArcGIS REST API, used for obtaining layer information / Getting layer information with the ArcGIS REST API and Python, How to do it…, How it works…
    • and ArcGIS REST API, used for exporting map / Exporting a map with the ArcGIS REST API and Python, Getting ready, How to do it…, How it works…
    • and ArcGIS REST API, used for querying map service / Querying a map service with the ArcGIS REST API and Python, How to do it…, How it works…
    • installing, for ArcGIS Pro / Installing Python for ArcGIS Pro
  • Python add-ins module
    • using / How to do it..., How it works...
  • Python Add-In Wizard
    • installing / Downloading and installing the Python Add-in Wizard, How to do it…
    • about / Getting ready
    • downloading / How to do it…
    • working / How it works…
  • Python exception handling structures
    • adding / Adding Python exception handling structures (try/except/else), Getting ready, How it works…
    • try/except statement / Getting ready
    • try/except/else statement / Getting ready
    • try block / Getting ready
    • try/except/else/finally / Getting ready
  • Python json module
    • used, for parsing HTTP response / Making HTTP requests and parsing the response with Python, How to do it…, How it works…
  • Python language fundamentals
    • about / Python language fundamentals
    • code, commenting / Commenting code
    • modules, importing / Importing modules
    • variables / Variables
    • built-in data types / Built-in data types
    • classes / Classes and objects
    • objects / Classes and objects
    • statements / Statements
    • file I/O / File I/O
  • Python prompt section
    • about / Using the new Python window in ArcGIS Pro
  • Python requests module
    • URL, for installing / How to do it…
    • about / Introduction
  • Python scripts
    • running, from command line / Running Python scripts from the command line, How to do it…, How it works…
    • adding, to batch files / Adding Python scripts to batch files, There's more...
  • Python setup file
    • URL, for downloading / Installing Python for ArcGIS Pro
  • Python toolbox
    • creating / Creating a Python toolbox, How to do it…, How it works…
  • Python window
    • using, in ArcGIS Pro / Using the new Python window in ArcGIS Pro

R

  • records
    • filtering, with where clause / Filtering records with a where clause, Getting ready, How it works…
  • replaceDataSource() method
    • used, for fixing individual layer / Fixing individual layer and table objects with replaceDataSource(), How to do it…, How it works…, There's more…
    • used, for fixing table objects / Fixing individual layer and table objects with replaceDataSource(), How to do it…, How it works…, There's more…
  • report
    • about / Exporting a report
    • exporting / Exporting a report, How to do it…, How it works…
  • Report Document File (RDF)
    • about / Getting ready
  • Report Layout File (RLF)
    • about / Getting ready
  • rows
    • selecting, with Select Layer by Attribute tool / Getting ready, How to do it…
    • selecting, with Select by Location tool / Selecting features with the Select by Location tool, How to do it…
    • inserting, with InsertCursor / Inserting rows with InsertCursor, How to do it…, How it works…
    • updating, with UpdateCursor / Updating rows with UpdateCursor, How to do it…, How it works…
    • deleting, with UpdateCursor / Deleting rows with UpdateCursor, How to do it…, How it works…
    • inserting, inside edit session / Inserting and updating rows inside an edit session, Getting ready, How to do it…, How it works…
    • updating, inside edit session / Inserting and updating rows inside an edit session, Getting ready, How to do it…, How it works…

S

  • script
    • geoprocessing tools, executing from / Executing geoprocessing tools from a script, How it works…
  • SearchCursor
    • about / Introduction
    • used, for retrieving features from feature class / Retrieving features from a feature class with SearchCursor, Getting ready, How it works…
  • Select by Location tool
    • used, for selecting features / Selecting features with the Select by Location tool, Getting ready, How to do it…
    • used, for combining spatial and attribute query / Combining a spatial and attribute query with the Select by Location tool, Getting ready, How to do it..., How it works...
  • selected features
    • zooming / Zooming in to selected features, How to do it…
  • selection methods
    • NEW_SELECTION / Getting ready
    • ADD_TO_SELECTION / Getting ready
    • REMOVE_FROM_SELECTION / Getting ready
    • SUBSET_SELECTION / Getting ready
    • SWITCH_SELECTION / Getting ready
    • CLEAR_SELECTION / Getting ready
  • Select Layer by Attribute tool
    • used, for selecting features / Selecting features and rows with the Select Layer by Attribute tool, Getting ready, How to do it…
    • used, for selecting rows / Selecting features and rows with the Select Layer by Attribute tool, Getting ready, How to do it…
  • Service Definition Draft
    • about / Publishing a map document to an ArcGIS Server service
  • slicing / String manipulation, Lists
  • spatial query
    • about / Introduction
    • combining with attribute query, Select by Location tool used / Combining a spatial and attribute query with the Select by Location tool, How to do it..., How it works...
  • specific error messages
    • testing for / Testing for and responding to specific error messages, How to do it…, How it works…
    • responding to / Testing for and responding to specific error messages, How to do it…
  • StageService Tool(.sd)
    • about / Getting ready
  • statements
    • about / Statements
    • decision statements / Decision support statements
    • looping statements / Looping statements
    • try statements / Try statements
    • with statements / With statements
    • statement indentation / Statement indentation
  • strings
    • about / Strings
    • string manipulation / String manipulation, Numbers
  • sys.argv[ ]
    • used, for capturing command-line input / Using sys.argv[ ] to capture command-line input, Getting ready, How to do it...

T

  • table objects
    • fixing, with replaceDataSource() method / Fixing individual layer and table objects with replaceDataSource(), How to do it…, How it works…, There's more…
  • table views
    • creating / Creating feature layers and table views, Getting ready, How to do it…, There's more...
    • about / Getting ready
  • time-enabled layers
    • working with, in data frame / Working with time-enabled layers in a data frame, How to do it..., How it works…
  • tool add-in
    • about / Creating a tool add-in, How it works...
    • creating / Getting ready, How to do it...
  • toolbox alias
    • retrieving / Retrieving a toolbox alias, How to do it…, How it works…
  • tool chaining
    • about / Using the output of a tool as an input to another tool
  • tool messages
    • retrieving, with GetMessages() / Retrieving tool messages with GetMessages(), Getting ready, How it works…
    • filtering, by level of severity / Filtering tool messages by the level of severity, How to do it…, How it works…
  • Transcript section
    • about / Using the new Python window in ArcGIS Pro
  • try statement
    • about / Try statements
    • try/except/else / Try statements
    • try/finally / Try statements
  • tuple, Python
    • about / Getting ready
  • tuples
    • about / Tuples

U

  • unique name
    • assigning, to layout elements / Assigning a unique name to layout elements, How to do it…, How it works…, There's more…
  • UpdateCursor
    • about / Introduction
    • rows, updating / Getting ready, How to do it…, How it works…
    • rows, deleting / Deleting rows with UpdateCursor, How to do it…, How it works…
  • UpdateLayer() function / Updating layer symbology, There's more...
  • UploadServiceDefinition Tool
    • about / Getting ready

V

  • ValueTable
    • used, for providing multivalue input / Using a ValueTable to provide multivalue input to a tool, How to do it…, How it works…
  • variables
    • about / Variables
    • naming rules / Variables
    • legal variable names / Variables
    • illegal variable names / Variables
    • dynamic typing / Variables
    • data types, assigning / Variables
  • views
    • data view / Getting ready
    • layout view / Getting ready

W

  • Walk() function
    • used, for navigating directories / Using Walk() to navigate directories, How to do it…, How it works…
  • warning messages / Getting ready
  • where clause
    • used, for filtering records / Filtering records with a where clause, Getting ready, How it works…
  • with statements
    • about / With statements
  • workspace / Getting ready

X

  • XML files
    • reading / Reading XML files, Getting ready, How to do it…, How it works…

Z

  • ZIP files
    • creating / Creating ZIP files, Getting ready, How to do it…