1

In GDAL >= 1.10, ogr2ogr contains osm driver

I want to try this feature and migrate OSM to PostGIS (I'm aware of osm2pqsql existence)

I have several relatively small OSM files and wonder if ogr2ogr driver will merge all features correctly or do I have to use other tool for merging (osmosis) before migrating to PostGIS?

  • You might encounter problems if items are included in both datasets. I have not tested it, but it might be that ogr2ogr refuses to proceed if an object is already in the Postgis database. – AndreJ Jun 19 '14 at 16:54
1

Depends on how "correctly" is defined. Ogr2ogr creates by default an attribute "ogc_fid" to the target dataset and that is used as primary key. Therefore if separate OSM datasets contain the same OSM features with same osm_id they can be appended into the same PostGIS tables. Osm2pgsql will fail in this situation because it creates tables which use osm_id as primary key. However, ogr2ogr does not merge the duplicate features but after conversion they will appear many times in PostGIS tables. Because osm_id is saved also as a normal attribute it is possible to find duplicate features with SQL and keep only one and delete the rest. Therefore my answer is "Yes".

  • osm2pgsql (as least the version I tried on Windows) does not create primary key, and I guess other OS versions does not too, as osm_id is not unique. – zetah Jun 19 '14 at 22:04
  • My version does but it may have changed:NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "planet_osm_ways_pkey" for table "planet_osm_ways" Osm_ids are unique per type node/way/relation though not universally. – user30184 Jun 20 '14 at 9:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.