Ebook Programming ArcGIS 10.1 with Python Cookbook

Programming ArcGIS 10.1 with Python Cookbook
Programming ArcGIS 10.1 with Python Cookbook



Nhà xuất bản Packt Publishing Ltd
Tác giả Eric Pimpler
Số trang 304
Ngày xuất bản 2013
File PDF

Chapter 1: Fundamentals of the Python Language for ArcGIS 7
Using IDLE for Python script development 8
Python language fundamentals 11
Summary 28

Chapter 2: Writing Basic Geoprocessing Scripts with ArcPy 29
Introduction 29
Using the ArcGIS Python window 30
Accessing ArcPy with Python 32
Executing tools from a script 35
Using ArcGIS Desktop help 39
Using variables to store data 42
Accessing ArcPy modules with Python 44

Chapter 3: Managing Map Documents and Layers 47
Introduction 47
Referencing the current map document 48
Referencing map documents on a disk 50
Accessing a data frame 51
Getting a list of layers in a map document 52
Restricting the list of layers 54
Changing the map extent 56
Getting a list of tables 58
Adding layers to a map document 59
Inserting layers into a map document 61
Updating layer symbology 64
Updating layer properties 66
Chapter 4: Finding and Fixing Broken Data Links 73
Introduction 73
Finding broken data sources in your map document and layer fles 74
Fixing broken data sources with MapDocument.
fndAndReplaceWorkspacePaths() 76
Fixing broken data sources with MapDocument.replaceWorkspaces() 79
Fixing individual Layer and Table objects with replaceDataSource() 82
Finding all broken data sources in all map documents in a folder 85

Chapter 5: Automating Map Production and Printing 89
Introduction 89
Creating a list of layout elements 90
Assigning a unique name to layout elements 92
Restricting the layout elements returned by ListLayoutElements() 97
Updating layout element properties 98
Getting a list of available printers 101
Printing maps with PrintMap() 102
Exporting a map to a PDF fle 103
Exporting a map to an image fle 105
Creating a map book with
PDFDocumentCreate() and PDFDocumentOpen() 106

Chapter 6: Executing Geoprocessing Tools from Scripts 109
Introduction 109
Finding geoprocessing tools 110
Retrieving a toolbox alias 114
Executing geoprocessing tools from a script 117
Using the output of a tool as an input to another tool 120
Setting environment variables and examining tool messages 122

Chapter 7: Creating Custom Geoprocessing Tools 125
Introduction 125
Creating a custom geoprocessing tool 125

Chapter 8: Querying and Selecting Data 143
Introduction 143
Constructing proper attribute query syntax 144
Creating feature layers and table views 150
Selecting features and rows with the Select Layer by Attribute tool 154
Selecting features with the Select by Location tool 157
Combining a spatial and attribute query with the Select by Location tool 161

Chapter 9: Using the ArcPy Data Access Module to Select, Insert,
and Update Geographic Data and Tables 165
Introduction 166
Retrieving features from a feature class with a SearchCursor 168
Filtering records with a where clause 170
Improving cursor performance with geometry tokens 172
Inserting rows with InsertCursor 175
Updating rows with an UpdateCursor 180
Deleting rows with an UpdateCursor 184
Inserting and updating rows inside an edit session 186
Reading geometry from a feature class 190

Chapter 10: Listing and Describing GIS Data 193
Introduction 194
Getting a list of feature classes in a workspace 194
Restricting the list of feature classes returned with a wildcard 196
Restricting the list of feature classes returned with a feature type 197
Getting a list of felds in a feature class or table 198
Using the Describe() function to return descriptive information
about a feature class 201
Using the Describe() function to return descriptive information
about an image 204
Returning workspace information with the Describe() function 206

Chapter 11: Customizing the ArcGIS Interface with Add-Ins 209
Introduction 209
Downloading and installing the Python Add-In wizard 210
Creating a button add-in 213
Installing and testing an add-in 223
Creating a tool add-in 227

Chapter 12: Error Handling and Troubleshooting 233
Introduction 233
Exploring the default Python error message 234
Adding Python exception handling structures (try/except/fnally) 235
Retrieving tool messages with GetMessages() 237
Filtering tool messages by severity level 238
Testing for and responding to specifc error messages 240
Returning individual messages with GetMessage() 242

Be the first to comment

Leave a Reply

Your email address will not be published.