OpenStreetMap – OSM PBF from Geofabrik Call with Bounding Box

geofabrikopen-source-routing-machineopenstreetmap

I want to use a limited area within a geofabrik dataset.

I am wondering if I can use a wget call with a boundig box limitation.

e.g. something like this.

wget http://download.geofabrik.de/europe/germany/berlin-latest.osm.pbf&bbox=144.887112,-37.856539,145.012768,-37.770152

Best Answer

If your aim is to download less data I don't believe it is possible but the whole .pbf file is downloaded in any case, but you can avoid using temporary files by piping the output of wget to osmconvert and let that take care of clipping https://wiki.openstreetmap.org/wiki/Osmconvert#Clipping_based_on_Longitude_and_Latitude

Tested on Windows, worked for me.

 wget -O - https://download.geofabrik.de/europe/andorra-latest.osm.pbf|osmconvert64 - -b=1.42,42.43,1.7,42.6 -o=test_clipped.pbf

Be careful with the syntax -O - directs wget output to standard out and - makes osmconvert to read standard in.

Check that the extent of the clipped point layer is correct.

 ogrinfo test.pbf points -so
 INFO: Open of `test.pbf'
       using driver `OSM' successful.

 Layer name: points
 Geometry: Point
 Feature Count: -1
 Extent: (1.420000, 42.430000) - (1.700000, 42.600000)