NOTICE: is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum


How to import India and GCC States data in local OSM server using osm2pgsql?

asked 28 Jan '16, 08:52

Reshma%20Maner's gravatar image

Reshma Maner
accept rate: 0%

Could you explain what GCC States is? Is it Gulf Cooperation Council States?

(28 Jan '16, 08:53) rorym

Yes. It is Gulf Cooperation Council States

(28 Jan '16, 08:57) Reshma Maner

Download both country files & merge them with osmconvert (easier to use, as has fewer dependencies, but less functional, than Osmosis). Then import using osm2pgsql.

Note that if you want to add additional countries with shared borders you will most likely have to reimport all the data.

permanent link

answered 29 Jan '16, 14:20

SK53's gravatar image

SK53 ♦
accept rate: 22%

Can I not use osm2pgsql --append option to import the second pbf file?

(30 Jan '16, 10:25) Reshma Maner

You can try it. Don't expect it to work at a reasonable speed, though - much faster to merge first and then load.

(or at least it was when I last tried it, and looked at the "append" code in osm2pgsql, around 3 years ago).

(30 Jan '16, 10:33) SomeoneElse ♦

How to merge .osm.pbf files. If I merge two files with these extensions and pass the merged file to osm2pgsql command, it gives error

(01 Feb '16, 07:38) Reshma Maner

Which error? And how did you merge them?

(01 Feb '16, 08:05) scai ♦

osmconvert india-latest.osm.pbf gcc-states-latest.osm.pbf -o=newmap.osm.pbf osmconvert Error: more than one .pbf input file is not allowed.

(01 Feb '16, 09:24) Reshma Maner


Can somebody help?

(02 Feb '16, 09:54) Reshma Maner

Maybe osmconvert can't merge PBF files directly and you have to convert them to another format before. Just a guess.

(02 Feb '16, 10:07) scai ♦

I did that too. I first converted both the pbf files to .osm files. Then merged the two .osm files into single one. Then converted back .osm to .osm.pbf.

But osm2pgsql command does not work with such created file.

(02 Feb '16, 10:19) Reshma Maner

Following steps work for me:

osmconvert gcc-state-latest.osm.pbf --out-o5m >gcc.o5m osmconvert india-latest.osm.pbf --out-o5m >india.o5m osmconvert india.o5m gcc.o5m --out-o5m > merged.o5m osmconvert merged.o5m --out-pbf >merged.pbf osm2pgsql -U postgres -d osm --host localhost -S -s -C 500 -k merged.pbf

The discrete conversion of the merged file from o5m to pbf might be doable in one step.

(02 Feb '16, 19:57) SK53 ♦
showing 5 of 9 show 4 more comments

You can download the full OSM planet file from, and then use osmosis to clip out the polygon(s) you want. You'll be left with a pbf file which you can import with osm2psql.

permanent link

answered 28 Jan '16, 08:54

rorym's gravatar image

accept rate: 11%

edited 28 Jan '16, 08:55

Can I not download two pbf files from geofabrik one for India and one for Gcc states and import both of them?

Do I need to install osmosis? How to do that?

(28 Jan '16, 08:56) Reshma Maner

The pbf files on Geofabrik don't follow exactly the borders of the respective countries, they simplify and go into the next country by maybe a few hundred metres, or so. Everything in the country is in the pbf file, but so is stuff from the neighbouring country. Hence importing 2 pbfs from countries that border each other will probably display OK for generating tiles, but not be very useful for say OSRM routing. India and GCC states appear to share no border, so that would be less of a problem

(28 Jan '16, 09:58) rorym
(28 Jan '16, 09:58) rorym offers extracts of self defined areas in one file but there is a size limit

(30 Jan '16, 11:42) nevw

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:


question asked: 28 Jan '16, 08:52

question was seen: 3,884 times

last updated: 02 Feb '16, 19:57

NOTICE: is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum