Chapter 11. Querying Geospatial Data

You can store a latitude and longitude in your database and make maps without PostGIS. We cannot, however, ask spatial questions of our data unless the database understands spatial concepts. That’s where PostGIS and the spatial SQL functions provided by PostGIS come into play.

In this chapter we look at the two most common spatial questions you will need to ask of your data: “What exists in this area?” and “What exists near this point?” Before we can answer the first question we need to discuss how to define that area. For that we use something called a bounding box.

Finding Items within a Bounding Box

Imagine that you are a logistics coordinator and you are responsible for the whereabouts of all of the assets ...

Get Data Visualization Toolkit: Using JavaScript, Rails™, and Postgres to Present Data and Geospatial Information 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.