[OSM-dev] Osmosis - Cutting out a bounding box from a diff file (.osc)

Stephan Knauss osm at stephans-server.de
Thu Sep 6 08:35:49 BST 2012


Stéphane Henriod writes: 

> My problem is that, despite the *osm2pgsql -b* option, it seems that my
> bounding box is ignored and the full diff file is added to my database, As
> a consequence, the database is growing very quickly and includes lots of
> data outside of my area of interest.

Only nodes have a coordinate, so only these can be checked against a 
bounding box. 

For ways and even worse relations you have to look up the coordinates of 
the member nodes and then decide on a strategy. Will you include ways where 
all nodes are inside you bbox or just a single? 

I thought about extending osm2pgsql but the runtime effort to fetch all 
this data is quite expensive when running minutely diffs. 

So I ended up with a simple query to clear up the DB. This runs by a cron 
job and removes excess data from the db within minutes. The vacuum taking 
the most time. 

Find it in the wiki:
http://wiki.openstreetmap.org/wiki/User:Stephankn/knowledgebase#Cleanup_of_w
ays_outside_the_bounding_box 

If you are happy with nodes and ways and don't need relations then the 
upcoming augmented diffs might be an option. 

Stephan



More information about the dev mailing list