OGR

We touched on OGR as a way to handle WKT strings, but its real power is as a universal vector library. This book strives for pure Python solutions, but no single library even comes close to the variety of formats that OGR can process.

Let's read a sample point shapefile using the OGR Python API. The sample shapefile can be downloaded as a ZIP file here: https://github.com/GeospatialPython/Learn/raw/master/point.zip

This point shapefile has five points with single digit, positive coordinates. The attributes list the order in which the points were created, making it useful for testing. This simple example will read in the point shapefile and loop through each feature; then it'll print the x and y value of each point plus the value of the first ...

Get Learning Geospatial Analysis with Python - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.