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

How to add only a few selected countries?

0

Hello,

How do I add a few selected countries only instead of adding the planet data? I used the following to add one,

osm2pgsql --slim -d gis --hstore --multi-geometry --number-processes 10 --tag-transform-script /home/osm/openstreetmap-carto/openstreetmap-carto.lua --style /home/osm/openstreetmap-carto/openstreetmap-carto.style -C 32000 /home/osm/qatar-latest.osm.pbf

Can I use the same command and add another one or am I doing something wrong?

asked 28 Jul '22, 09:21

praveen_aps's gravatar image

praveen_aps
16113
accept rate: 0%

edited 30 Jul '22, 05:13


One Answer:

3

The safest approach is downloading a continent or planet file, then using osmium to cut out the area that interests you, resulting in one single file to import, then import that.

Alternatively, download individual countries, merge them with osmium, resulting in one single file, then import that.

Importing individual countries one after the other is not recommended, it is much slower than the approaches above.

answered 28 Jul '22, 09:32

Frederik%20Ramm's gravatar image

Frederik Ramm ♦
82.5k927201273
accept rate: 23%

Thanks for your response, although may I ask if there's any drawback to doing so apart from it being slower? because we'd like to add more countries as and when required.

(28 Jul '22, 09:57) praveen_aps
2

Being slower is the only drawback but depending on your setup you will find that it can take two weeks to add a country that way when it would take two hours to do a full import on a clean database. Just try it out, maybe you'll be lucky. What you need to do is convert the .osm.pbf that you want to add to an .osc file by using osmium --derive-changes to compute the changes between an empty file and the .osm.pbf you want to add. Then use osm2pgsql --append to append the .osc file to your database.

(28 Jul '22, 10:13) Frederik Ramm ♦

Thank you, I'll try that out

(28 Jul '22, 10:35) praveen_aps

Source code available on GitHub .