Book Image

ArcPy and ArcGIS: Geospatial Analysis with Python

Book Image

ArcPy and ArcGIS: Geospatial Analysis with Python

Overview of this book

Table of Contents (19 chapters)
ArcPy and ArcGIS – Geospatial Analysis with Python
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Getting field information from feature classes


When creating script tools, or just running a script, there can be times that extracting field information from a feature class (or shapefile) is necessary. This information can include field names and aliases, field type and length, scale, domains, or subtypes. These are all properties available through the arcpy.ListFields method. We'll explore the many properties, how to extract them, and how to use them in a script.

By organizing the ArcPy methods into a function, the data is organized in a form that we prefer, instead of relying on the default organization used by the designers of ArcPy. It's important to remember that scripts you create should reflect your needs, and creating these function wrappers is one step forward towards polishing the raw ArcPy tools to work in your workflows.

Accessing the ListFields' properties

The List Fields tool is available as an ArcPy method. Arcpy.ListFields accepts only one parameter, a feature class, or shapefile...