Processing Open Street Map Data with Python and PostgreSQL
- Author: Travis Hathway
- Talk page: https://2022.pycon.de/program/AKCLEP/
- Blog about the talk: https://travishathaway.com/posts/2022-04-02-processing-osm-data-with-postgresql-and-python/
Topics
- What is OSM?
- How to use OSM with Posgres / postGIS?
- How to structure a Python project for these use cases?
OSM
- Huge community
- Contribued by:
- Individual
- organizations
- Government
Data types:
- Node --> Point
- Ways --> Collection of points. e.g. street, river
- Closed ways
- areas --> parks
- Relations --> Lakes with island
Tagging features
- Community has some standards of tagging
- e.g of tags Cinema, restaurant etc.
OSM Mirrors
- Most common geofabrik mirror
Formats in OSM:
- Supports multiple formats for exporting
- Preferred: Protocolbuffer Binary Format (PBF)
OSM with Postgres:
- PostGIS: Postgres extension for GIS
- Data type --> Geometry which can be classified into
- Point [OSM Nodes]
- LineString [Ways, Open Ways]
- Polygon [Closed ways, relations]
-
Geometry Collection [Closed ways, relations]
- Multipoint
- Multiline
- Multipolygon
-
Check PostGis tutorial for Geospatial queries.
How to get data to database:
- OSmimum
- OSM2psql
- Can use Lua scripts
Structure of Python project

Summary:
graph LR
Download --> Extract --> Import --> Report