更新时间:2021-07-02 21:45:50
coverpage
Title Page
Credits
Foreword
About the Authors
About the Reviewers
www.PacktPub.com
Why subscribe?
Customer Feedback
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
Introduction to Python for ArcGIS
Python as a programming language
Interpreted language
Standard (built-in) library
Glue language
Wrapper modules
The basics of Python programming
Import statements
Variables
For loops
If/Elif/Else statements
While statements
Comments
Data types
Strings
Integers
Floats
Data containers
Zero-based indexing
Lists
Tuples
Dictionaries
Other important concepts
Indentation
Functions
Keywords
Namespaces
Important Python modules
The OS (operating system) module
The sys (Python system) module
The CSV XLRD and XLWT modules
Commonly used built-in functions
Standard library modules
How Python executes a script
What is a Python script?
Python interpreter
Where is the Python interpreter located?
Which Python interpreter should be used?
How does the machine know where the interpreter is?
Make Python scripts executable when clicked
Integrated Development Environments (IDEs)
IDLE
PythonWin
Atom Notepad++ and Sublime Text
IDE summary
Python folder structure
Where modules reside
Installing a third-party module
Using Python's sys module to add a module
The sys.path.append method
Summary
Creating the First Python Script
Prerequisites
ModelBuilder
Creating a model and exporting to Python
Modeling the Select and Buffer tools
Adding in the Intersect tool
Tallying the analysis results
Exporting the model and adjusting the script
The Automatically generated script
File paths in Python
String manipulation
String manipulation method 1: string addition
String manipulation method 2: string formatting #1
String manipulation method 3: string formatting #2
The ArcPy tools
The Intersect tool
Adjusting the script
Adding the CSV module to the script
Accessing the data: using a cursor
Exceptions and tracebacks
Overwriting files
The final script
ArcPy Cursors - Search Insert and Update
Python functions – avoid repeating code
Technical definition of functions
The first function
Functions with parameters