Skip to content

trufi-association/trufi-pbf-extractor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Trufi PBF Extractor

Extract OpenStreetMap PBF sub-regions from country-level data using a bounding box.

Requirements

Quick Start

  1. Clone the repository

    git clone https://github.com/trufi-association/trufi-pbf-extractor.git
    cd trufi-pbf-extractor
  2. Create your configuration

    cp .env.example .env
  3. Edit .env with your city's values (see Configuration section below)

  4. Run the extractor

    docker-compose up --build
  5. Find your output in ./data/<city_name>.osm.pbf

Configuration

Edit the .env file with these variables:

Variable Description Example
CITY_NAME Name for the output file kigali
BBOX Bounding box (west,south,east,north) 29.979526,-2.079821,30.27987,-1.779581
GEOFABRIK_URL_PATH Path to country PBF on Geofabrik /africa/rwanda-latest.osm.pbf

How to get the values

Bounding Box:

  1. Go to boundingbox.klokantech.com
  2. Navigate to your city and draw a box around the area you want
  3. Select "CSV" format at the bottom
  4. Copy the coordinates (format: west,south,east,north)

Geofabrik URL Path:

  1. Go to download.geofabrik.de
  2. Navigate to your continent → country
  3. Copy the path after download.geofabrik.de (e.g., /africa/rwanda-latest.osm.pbf)

Example Configurations

Kigali, Rwanda

CITY_NAME=kigali
BBOX=29.979526,-2.079821,30.27987,-1.779581
GEOFABRIK_URL_PATH=/africa/rwanda-latest.osm.pbf

Quito, Ecuador

CITY_NAME=quito
BBOX=-78.669528,-0.416925,-77.958163,0.504543
GEOFABRIK_URL_PATH=/south-america/ecuador-latest.osm.pbf

Cochabamba, Bolivia

CITY_NAME=cochabamba
BBOX=-66.227,-17.478,-66.086,-17.329
GEOFABRIK_URL_PATH=/south-america/bolivia-latest.osm.pbf

Output

The extracted PBF file will be saved to:

./data/<CITY_NAME>.osm.pbf

You can use this file with:

Troubleshooting

Docker is not running

# Check if Docker is running
docker ps

# Start Docker Desktop or the Docker daemon

Permission denied on data folder

# Create the data folder with proper permissions
mkdir -p data
chmod 755 data

Download fails

Empty or very small output file

  • Verify your bounding box coordinates are correct
  • Make sure west < east and south < north
  • Check that your bbox is within the country boundaries

How It Works

  1. Downloads the country-level PBF from Geofabrik
  2. Uses osmium-tool to extract the specified bounding box
  3. Saves the result to the mounted data volume

License

MIT License - see LICENSE for details.

Credits

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •