Skip to content

nicolaslazo/osm-bsas-building-import

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OpenStreetMap Buenos Aires City Dataset Import

PostgreSQL PostGIS Python OSM Leer en Español

A toolset for importing, cleaning, and processing Buenos Aires building data from official government sources into OpenStreetMap-compatible format.

Context & Purpose

This project bridges official Buenos Aires building data with OpenStreetMap by:

  • Using authoritative city dataset geometries and attributes
  • Cross-referencing with live OSM data to prevent duplicates
  • Cleaning and transforming data through SQL migrations
  • Generating OSM changefiles chunked by city blocks ("manzanas")

Project Structure

  • bin/ - Helper scripts:
    • download-dataset.sh - Fetches the Buenos Aires urban fabric dataset
    • import-datasets.sh - Imports city and OSM data into PostgreSQL/PostGIS
    • run-migrations.sql - Executes SQL migration scripts for data transformation
    • export-geojson.sh - Exports query results as GeoJSON for debugging
  • examples/ - Example GeoJSON files for some of the addressed issues
  • migrations/ - SQL and Python scripts for data transformation
  • changesets/ - Output directory for generated OSM changefiles

Getting Started

1. Download Datasets

  1. Go to Overpass Turbo

  2. Paste the following query:

    [out:json][timeout:900];
    area["name"="Buenos Aires"]["boundary"="administrative"]["admin_level"="8"]->.searchArea;
    (
      way["building"](area.searchArea);
      relation["building"](area.searchArea);
    );
    out body;
    >;
    out skel qt;
    
  3. Run the query, then use Export > GeoJSON to save as data/live-osm-data.geojson

  4. Run the dataset download script:

bin/download-dataset.sh

This script will save the contents to data/tejido.geojson.

2. Import Datasets into PostgreSQL/PostGIS

Start the database:

docker compose up -d

Import the datasets:

bin/import-datasets.sh

3. Run Data Cleaning and Transformation

bin/run-migrations.sql

4. Generate OSM Changefiles

uv run migrations/500-create-changefiles.py

Changefiles will be available in the changesets/ directory, organized by city block.

Requirements

  • Docker Compose for PostgreSQL/PostGIS
  • Python 3.12+
  • uv package manager
  • GDAL with ogr2ogr

Visualization

To visualize the processing results:

bin/export-geojson.sh "SELECT * FROM processed_buildings LIMIT 100" > debug.geojson

Then open the file in QGIS or any GeoJSON viewer.

References

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contributing

Contributions are welcome! Feel free to:

  • Report issues
  • Suggest improvements to the processing pipeline
  • Add new data cleaning rules
  • Enhance documentation

About

OpenStreetMap Buenos Aires City Dataset Import

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors