Using a spatial filter to select features

This example uses the Natural Earth Dataset introduced in Chapter 4Data Types, Storage, and Conversion, under the Reading and writing vector data with GeoPandas section. We'll use latitude-longitude coordinates to create a spatial filter in the form of a bounding box. This box selects only the data inside of this box. This is a way to work with a subset of our data. We'll use OGR's SpatialFilterRec method, which takes four values—minx, miny, maxx and maxy, to create a bounding box. Our (random) example is to select the cities in our bounding box (which shows the state of Texas, as well as parts of Oklahoma and Mexico). To filter our results even further, we only want the cities in the US. This means ...

Get Mastering Geospatial Analysis with Python 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.