This is a static archive of our old OpenStreetMap Help Site. Please post any new questions and answers at community.osm.org.

How to maintain a local copy of a specific area of the OSM database

0

I would like to maintain a partial mirror of the OSM database, so to be able to keep - and to fetch only the updates - of that specific area, that would be custom (the Alpine area) without the need to maintain a copy of the whole world.

One purpose of that, would be to monitor daily changes for that area (simply out of curiosity), another - way more important - would be to be able to generate mapsforge map files that are very up-do-date without downloading the whole data for the area any time.

I was only able to find how to run a complete Planet mirror though. Is it possible to only mirror a part of the Planet? If so, how?

If that's not possible, what is the best way to keep a local OSM copy and fetch only the updates whenever I want to? There is plenty of documentation out there, but I am unable to realize what is the best road to follow (ie overpass vs postgresql, as far as I was able to understand). Thanks!

asked 30 Apr '15, 14:27

Superfebs's gravatar image

Superfebs
11113
accept rate: 0%


One Answer:

3
  1. create sub-section of planet file ("alpine.osm.pbf" or so) with osmosis and the --bp task (requires a .poly file describing the area)
  2. create initial state.txt file for osmosis replication (file must contain timestamp of when your base snapshot was taken)
  3. initialize osmosis replication (--rrii)
  4. run osmosis to update your file like so: osmosis --rri --simc --read-pbf alpine.osm.pbf --ac --bp file=alpine.poly clipIncompleteEntities=yes --write-pbf alpine-new.osm.pbf
  5. mv alpine-new.osm.pbf alpine.osm.pbf (or you can even compute the differences before you do)
  6. goto 4 as often as you want

This method downloads the world-wide diffs, applies them to your file (so that for a moment a new tree mapped in South America would be added) but then immediately cuts out your area of interest again so that only the bits that apply to your area are saved, and you will always have a current .osm.pbf file of your region.

Import into a database with osm2pgsql at will, but it's not necessary. Depends on what you want to do with the data.

answered 30 Apr '15, 14:53

Frederik%20Ramm's gravatar image

Frederik Ramm ♦
82.5k927201273
accept rate: 23%

Thank you. I'll tackle one step at a time. For what matters the first one, is there any GUI tool to generate a .poly file? (Sorry, I am a newbie).

(30 Apr '15, 14:59) Superfebs
(30 Apr '15, 15:24) aseerel4c26 ♦
2

There is also good advice here: https://wiki.openstreetmap.org/wiki/User:EdLoach#Osmosis_to_keep_a_local_copy_of_a_.osm_file_updated and Zverik's tools are very useful https://github.com/Zverik/regional particularly limit_osc.py.

JOSM or QGIS can be used to create .poly files

(30 Apr '15, 15:43) SK53 ♦

Source code available on GitHub .