Combine OpenStreetMap extracts
We discussed previously how to import a single OpenStreetMap extract and avoid processing the huge, complete OSM dataset. What if your area of interest is smaller than the whole planet, but larger than a single extract?
This is what the Luxembourg extract from the previous article looks like.

But what if we want Belgium, Netherlands and Luxembourg?
Osmosis to the rescue. Osmosis is a powerful tool with many options, we'll look at only at the merge option.
- Download the extracts - These were from GEOFABRIK
- Merge the extracts with osmosis.
- Import the merged extract.
- Set your chosen bounding box in ~/mapnik/generate_image.py. I used
ll = (2.54695,49.44722, 7.22760,53.62990) # Benelux - Render your custom area of interest
cd ~/mapnik
source ./set-mapnik-env
./customize-mapnik-map >$MAPNIK_MAP_FILE
./generate_image.py
cd ~/osmosis/bin/osmosis from this example you can see that the
./osmosis --rx ~/extracts/belgium.osm.bz2 --rx ~/extracts/netherlands.osm.bz2 --rx ~/extracts/luxembourg.osm --merge --merge --wx ~/mapnik/benelux.osm--read-xml
task will work on the bz2-compressed files as well as plain .osm files. If you are merging only two .osm files, omit the second --merge
.
cd ../src/osm2pgsql/
./osm2pgsql --slim -d gis ~/mapnik/benelux.osm
And enjoy your newly created, custom area of interest.

Credits
Article © 2009 CCBY R.Weait.
Map images and data © 2009 CCBYSA OpenStreetMap and contributors.




Thanks for this article, it
Thanks for this article, it was the reason for me to have a closer look at Osmosis.
But finally I found out that osm2pgsql takes several .osm files as input so it is unnecessary to stick them first together using Osmosis (in case you want to load the data into PostGIS).
Post new comment