O'Reilly logo

Python Geospatial Analysis Cookbook by Michael Diener

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Conducting a complex spatial analysis query using ST_Distance()

Now let's check for a more complex query in PostGIS to get our spatial juices flowing. We want to locate all the golf courses that are either inside or within 5 km of a national park or protected area. Plus, the golf course must be within 2 km of a city. The city data is derived from the tags in OSM where the tag place = city.

The national parks and protected areas for this query belong to the Government of Canada. Our golf courses and datasets of cities are derived from an OSM located in British Columbia and Alberta.

Getting ready

We need the data of all the national parks and protected areas in Canada, so go and make sure they're located in the /ch04/geodata/ folder.

The original data ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required