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

Inserting a polyline geometry


To create and insert a polyline-type shape field from a series of points, it's best to use the SHAPE@ keyword. We will also further explore the ArcPy Geometry types, which will be discussed in the next chapter. When working with the SHAPE@ keyword, we have to work with data in ESRI's spatial binary formats, and the data must be written back to the field in the same format using the ArcPy Geometry types.

To create a polyline, there is one requirement, at least two valid points made of two coordinate pairs. When working with the SHAPE@ keyword, there is a methodology to converting the coordinate pairs into an ArcPy Point and then adding it to an ArcPy Array, which is then converted into an ArcPy Polyline to be written back to the shape field:

listOfPoints = [(6002672.58675, 2092447.04362),
               (6003672.58675, 2093447.04362),
               (6004672.58675, 2094447.04362)
               ]
line = 'New Bus Line'
lineID = 12345
busLine = r'C:\Projects\PacktDB...