Index
A
- Analysis Gallery, 54
- Analysis Tools, 53
- ArcGIS Desktop 10.x, using IDEs for, 47–49
- ArcGIS Pro. See also ArcPy, Python
- API for Python, 16–17
- copying shapefiles to a geodatabase in, 7–9
- creating points along a line in, 9–12
- editing in (See integrated development environments (IDEs))
- geoprocessing in (See geoprocessing)
- help pages in, 186–89
- layers, 360–69
- licenses, 182–86
- maps, map frames, and cameras in, 357–59, 384–85
- Python as programming language of choice for, 1–2
- rasters in (See rasters)
- Spatial Analyst and Image Analyst modules, 315–16
- spatial data in (See spatial data)
- using scripting in, 3
- ArcObjects, 55
- ArcPy, 133. See also rasters
- ArcGIS Pro help pages in, 186–89
- coordinate systems, 170–74
- data descriptions in, 194–98
- environments, 174–75
- functions, 166–67
- geoprocessing tools in, 158–63
- importing, 156
- introduction to, 155
- listing data in, 199–212
- lists in, 214–17
- mapping module (See map scripting)
- rasters in (See rasters)
- setting up workspace in, 157–58
- tool messages, 175–82
- tool parameters, 168–70
- working with ArcGIS Pro licenses, 182–86
- working with Result object in, 163–64
- working with toolboxes in, 165–66
- ASCII (American Standard Code Information Interchange), 96
- assignment statement, 89
- autocompletion prompts, 41–42
B
- backslashes, 128–30, 139–40
- backward compatibility of Python, 4
- bands, raster, 313–14
- batch mode, 67–68
- batch processing, 67–74
- Batch Project script, 82
- blocks, code, 135–36
- Boolean expressions, 111–12
- Boolean logic, 111–14
- Boolean operators, 112
- Booleans, 86
- branching, 133–34
- breakpoints, 229
- buffer tools, 55
- built-in tools, 55
C
- C++, 90
- cameras, 384–85
- Cartographic Information Model (CIM), 388–89
- Cartography Tools, 53
- casting, 96
- catalog paths, 194
- cells, raster, 313–14
- classes
- arcpy.sa and arcpy.ia modules, 334–39
- exceptions and custom, 239–40
- for tool parameters, ArcPy, 168–70
- Clip tools, 56–60, 158–63
- Clone Default button, 24–25
- code
- coding standards and guidelines, 149–50
- color symbology
- command line prompt, 15–16
- commenting out code, 228–29
- comments, 146–49
- comparison operators, 133–34
- compound statements, 135–36
- conda, 23
- conditional statements, 133–35
- connectors, 75
- continuous rasters, 314
- control structures, 135
- coordinate systems, ArcPy, 170–74
- copying shapefiles to a geodatabase, 7–9
- creating points along a line, 9–12
- CSV files, 282–85
- current workspace setting, 64
- cursors, 247–53
- setting spatial references with, 308–10
- custom classes, 239–40
- custom tools, 56
D
- data frames, 356
- dataset, raster, 313, 319–24
- data structures, 86. See also rasters
- spatial data
- tabular data
- data types in Python, 4, 86. See also spatial data
- debugging and error handling
- adding print messages to scripts in, 227–28
- carefully reviewing the content of error messages in, 225–26
- for exceptions, 234–35
- handling exceptions in, 237–40
- introduction to, 219
- other methods of, 244
- procedures in, 224–34
- raising exceptions in, 235–37
- recognizing exceptions in, 224
- selectively commenting out code in, 228–29
- syntax errors, 94, 219–24
- tips and tricks for, 234
- using a Python debugger in, 229–34
- watching for common errors in, 244–45
- descriptions, data, 194–98
- dictionaries, 123–25
- directory, 144–45
- documentation and resources, Python, 85–86
- dynamic naming, 69–74
E
- Eclipse, 33
- editors, Python. See integrated development environments (IDEs)
- elements of models, 74–75
- encoding, 46
- environment settings in geoprocessing, 64–67
- errors
- common, 244–45
- error codes, 40–44
- handling, for exceptions, 234–35
- handling geoprocessing exceptions and, 241–43
- other methods for handling, 244
- raising exceptions and, 235–37
- reviewing the content of messages regarding, 225–26
- syntax, 94, 219–24
- try-except statement for handling, 237–40
- exceptions, 224
- exit condition, 137
- exponent operator, 88
- exporting and printing layouts, 386–88
- expressions and statements, writing of, 92–93
- exterior ring, 299
F
- factory code, 171
- field calculations, 262–74
- file extensions, 146
- file management, 144–46
- floats, 86, 87–89
- floor division, 87–88
- for loops, 212–14
- formatting, string, 108–10
- f-strings, 110
- functions, 99–102
- functions, ArcPy, 166–67
G
- Geocoding Tools, 53
- geometries
- geometry objects and tokens, 287–88
- geoprocessing tools and, 310–11
- introduction to, 287
- multipart features with, 296–99
- polygons with holes, 299–301
- reading, 292–96
- understanding geometry objects and, 288–92
- using cursors to set spatial reference, 308–10
- writing, 301–8
- geoprocessing
- batch processing and dynamic naming in, 67–74
- common errors in, 244–45
- defined, 51
- exception handling for, 241–43
- framework for, 51–52
- introduction to, 51
- raster analysis using, 326–29
- running scripts as tools in, 81–82
- specifying environment settings in, 64–67
- toolboxes and tools for, 52–55
- tool dialog boxes, 56–63
- types and categories of tools for, 55–56
- using ArcPy (See ArcPy)
- using geometry objects to work with, 310–11
- using models and ModelBuilder in, 74–78
- using scripting, 78–83
- graduated color symbology, 376–78
- Graphic Buffer, 55
H
- history and versions of Python, 3–5
I
- Image Analyst module, 315–16
- imagery, 313
- immutable strings, numbers, and tuples, 86
- implied line continuation, 140–42
- indentation, 38, 135–36, 221
- index, 86
- indexing, 105
- inline variable substitution, 69
- insert cursors, 247–53
- integers, 86, 87–89, 143
- Integrated Development Environment (IDLE), 17–23
- ArcGIS Desktop 10.x, 47–49
- ArcPy and, 156
- Clip tool in, 79–80
- command prompt in, 31–33, 36
- comments in, 146–47
- debugging in, 228–29, 232–33
- error messages in, 226
- infinite loops in, 137
- Python documentation and resources in, 85
- spell checker in, 220
- stand-alone script in, 178
- user input in, 143
- integrated development environments (IDEs). See also Python window
- for ArcGIS Desktop 10.x, 47–49
- Integrated Development Environment (IDLE), 17–23
- introduction to, 15
- other code editors as, 33
- PyCharm, 29–33
- Python scripts in, 34–35
- Spyder, 23–29
- use of, 15–17
- interior ring, 299
- iterable objects, 119–20
- iteration, 67
- iterator, raster cell, 339–43
J
- Java, 90
- Jupyter Notebook, 16
L
- layers, 360–64
- adding, removing, inserting, and moving, 364–69
- applying symbology to raster, 378–80
- working with symbology of, 370–76
- layouts, 356, 381–84
- exporting and printing, 386–88
- library, 23
- licenses, ArcGIS Pro, 182–86
- listing data, 199–203
- lists, 97, 114–21, 214–17
- loading code into Python window, 46–47
- long lines of code, 139–42
- looping structures, 137–38
- loops, for, 212–14
- loop variable, 137
M
- map algebra operators, 329–34
- map frames, 384–85
- map scripting
- accessing project properties and methods, 354–56
- adding, removing, inserting, and moving layers in, 364–69
- applying graduated color symbology in, 376–78
- applying symbology to raster layers in, 378–80
- Cartographic Information Model (CIM), 388–89
- exporting and printing layouts in, 386–88
- introduction to, 351
- layers, 360–64
- referencing projects, 352–54
- working with layer symbology in, 370–76
- working with layouts in, 381–84
- working with maps, map frames, and cameras in, 384–85
- working with maps in ArcGIS Pro in, 357–59
- working with the ArcPy mapping module in, 351–52
- math toolset, 329–34
- methods, 102–3
- Microsoft Visual Studio, 33
- ModelBuilder, 74–78
- model process, 75
- model tools, 55, 74–78
- modules, 34–35, 130–33
- modulus, 88
- multiband rasters, 322–24
- multiline construct, 37–38
- multipart features, 296–99
- multipoints, 297
- mutable lists and dictionaries, 86
O
- object-oriented programming, 97–99
- objects, geometry, 287–88
- objects, raster, 317–19
- Open Geospatial Consortium (OGC), 172–73
- operands, 87
- operator, 87
P
- package managers, 23
- packages
- pane, 35
- parsing of table and field names, 261–62
- paths, 128–30
- pixels, 313
- polygons with holes, 299–301
- printing
- and exporting map layouts, 386–88
- and string formatting, 108–10
- print messages added to scripts, 227–28
- programming versus scripting, 2–3
- properties, basic project, 354–56
- PyCharm, 29–33, 144, 222–23, 229
- debugging in, 233–34
- error checking in, 222
- infinite loops in, 137
- PyDev module, 33
- Python. See also ArcGIS Pro
- CIM access using, 388–89
- copying shapefiles to a geodatabase in, 7–9
- creating points along a line in, 9–12
- CSV files and, 282–85
- editors in (See integrated development environments (IDEs))
- exploring the features of, 1–2
- field calculations in, 262–74
- history and versions of, 3–5
- introduction to, 1
- modules in, 34–35
- as a scripting language, 2–3
- text files in, 274–82
- using SQL expressions in, 254–58
- window (See Python window)
- Python Enhancement Proposals (PEPs), 149
- Python environment, 16
- Python language fundamentals
- Boolean logic, 111–14
- commenting scripts, 146–49
- compound statements and indentation, 135–36
- controlling workflow using conditional statements, 133–35
- controlling workflow using looping structures, 137–38
- data types and structures, 86
- dictionaries, 123–25
- file management, 144–46
- following coding guidelines, 149–50
- functions, 99–102
- getting user input, 143–44
- introduction to, 85
- lists, 97, 114–21
- locating Python documentation and resources and, 85–86
- long lines of code, 139–42
- methods, 102–3
- modules, 130–33
- numbers, 87–89
- paths, 128–30
- printing and string formatting, 108–10
- Python objects, 97–99
- sets, 125–27
- strings, 93–96, 103–8
- tuples, 121–22
- variables and naming, 89–92
- writing statements and expressions, 92–93
- Python Library Reference, 86
- Python objects, 97–99
- Python Package Manager, 23–24
- Python Shell, 17
- Python window, 33–34, 35–39, 144
- exploring options in, 45
- getting assistance in, 40–44
- loading code into, 46–47
- saving work in, 45–46
- writing and running code in, 35–39
R
- raster layers, applying symbology to, 378–80
- rasters
- arcpy.sa and arcpy.ia modules and, 334–39
- describing properties of, 319–24
- geoprocessing tools and, 326–29
- introduction to, 313
- listing, 325–26
- map algebra operators and, 329–34
- multiband, 322–24
- NumPy arrays and, 346–49
- Spatial Analyst and Image Analyst modules and, 315–16, 343–46
- understanding, 313–14
- working with raster cell iterator, 339–43
- working with raster objects, 317–19
- raw strings, 129
- replacement field, 109
- Result object in ArcPy, 163–64
- ring, 299
S
- saving work in Python window, 45–46
- scheduled tasks, 83
- scratch workspace, 65
- scripting
- script tools, 55, 81–82
- search cursors, 247–53
- secondary prompt, 38
- sentry variable, 137
- sequence, 86
- sets, 125–27
- slicing, 105
- snake case, 92
- snippet, 35
- spacing, 221
- Spatial Analyst module, 315–16, 343–46
- spatial data
- checking for existence of, 193–94
- CSV files, 282–85
- describing, 194–98
- field calculations, 262–74
- introduction to, 193
- listing, 199–203
- lists, 214–17
- parsing table and field names in, 261–62
- text files with, 274–82
- using cursors to access, 247–53
- using lists in for loops, 212–14
- using SQL expressions in Python for, 254–58
- working with table and field names in, 259–61
- workspaces and listing, 204–12
- spatial reference set with cursors, 308–10
- spatial resolution, 314
- spell checking, 220
- Split By Attributes tool, 81–82
- Spyder (Scientific Python Development Environment), 23–33, 224, 229
- SQL expressions in Python, 254–58
- statements and expressions, writing of, 92–93
- string literal, 93
- strings/string values, 86, 93–96
- language for working with, 103–8
- printing and string formatting, 108–10
- Structured Query Language (SQL). See SQL expressions in Python
- Style Guide for Python Code (PEP 8), 91, 92, 139, 149, 163
- symbology
- applied to raster layers, 378–80
- applying graduated color, 376–78
- working with layers, 370–76
- syntax errors, 94, 219–24
- system languages, 2–3
- system paths, 194
- system tools, 56
T
- table and field names, 259–61
- tabular data
- CSV files, 282–85
- field calculations, 262–74
- parsing table and field names in, 261–62
- text files with, 274–82
- using cursors to access, 247–53
- using SQL expressions in Python for, 254–58
- working with table and field names in, 259–61
- Task Scheduler, 83
- text files, 274–82
- TIFF images, 201
- tokens, 287–88
- toolboxes in ArcPy, 165–66
- tool dialog boxes, 56–63
- tool messages, ArcPy, 175–82
- tool parameters, 56–58, 168–70
- tools, geoprocessing
- running scripts as, 81–82
- toolboxes and, 52–55
- tool dialog boxes for, 56–63
- types and categories of, 55–56
- traceback, 235
- true division, 87
- try-except statement, 237–39
- tuples, 121–22
U
- Unicode strings, 96
- Universal Transverse Mercator (UTM) coordinates, 308
- unnamed exception, 237
- update cursors, 247–53
- user input, 143–44
- UTF-8 (8-bit Unicode Transformation Format), 96
V
- variables, 75, 89–92
- versions of Python, 3–5
- virtual environments, 16
- Visual Studio, 33