Getting Started with OpenStreetMap and PostGIS

Alexander Vingardt
The Startup
Published in
5 min readJan 19, 2020

--

If you love maps and databases, this article is for you.

PostGIS is a PostgreSQL extension that adds support for geospatial data. OpenStreetMap is a global collaborative project that offers a publicly available map of the world. It generally provides great detail and coverage.

In this article we will load a map of Florida and run a few queries to get us acquainted with the data set.

Step 1 — downloading data

It’s always best to download the smallest data set possible — just enough to get things done. Geofabrik is the go-to place for finding OSM maps broken down by region.

Florida file can be found here.

Step 2 — extracting data

The file we just downloaded contains a plethora of data that we won’t be needing such as water bodies, supermarkets and gas stations to name a few.

In this article we will be working with cities and state and county borders.

Filtering out data we won’t be using speeds up the loading process as well as helps us keep our database lean.

My personal favorite for this task is osmium. It’s fast and lightweight. On a Mac you can install with —

brew install osmium-tool

Once you have it installed, let’s run the tool —

osmium tags-filter florida-latest.osm.pbf n/place=city,town…

--

--