2

I'm trying to import some OSM data into psql as equirectangular projection using osm2pgsql with the following command:

osm2pgsql -c -d osm -S /usr/local/share/osm2pgsql/default.style -l /OPENSTREETMAP/south-america-latest.osm.pbf

However, it fails with this error:

Projection code failed to initialise

I have installed the latest version of the PROJ framework from here.

What am I doing wrong?

EDIT 1:

Running 'select * from spatial_ref_sys where srid=4326;' on the database produces this:

 srid | auth_name | auth_srid |                                                                                                                              srtext                                                                                                                              |              proj4text               
------+-----------+-----------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------------------------------
 4326 | EPSG      |      4326 | GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4326"]] | +proj=longlat +datum=WGS84 +no_defs 
(1 row)
6
  • What does select * from spatial_ref_sys where srid=4326; run on the database report? Apr 8, 2014 at 3:50
  • Paul Norman: see Edit 1 above. Apr 8, 2014 at 9:06
  • Did you install osm2pgsql from source? It looks like the error is coming from osm2pgsql, not PostGIS. If your proj framework and osm2pgsql both came packaged, it's possible they're not talking to each other properly. Building osm2pgsql from source would probably fix that. If not, you might need to file an issue at github.com/openstreetmap/osm2pgsql/issues Apr 8, 2014 at 10:08
  • I just tried to install from source (following the instructions ending with './autogen.sh && ./configure && make'. Now when I try to run the command, it says: '-bash: /usr/local/bin/osm2pgsql: is a directory' Apr 8, 2014 at 11:32
  • You need to specify the osm2pgsql you compiled, probably with ~/osm2pgsql/osm2pgsql -c -d osm -S /usr/local/share/osm2pgsql/default.style -l /OPENSTREETMAP/south-america-latest.osm.pbf. The exact path will depend on where you downloaded osm2pgsql and built it. Apr 8, 2014 at 21:37

2 Answers 2

1

Make sure that your version of osm2pgsql is built for the version of postgis you have.

There were some major changes in postgis 2.0.

It might help to run the legacy.sql to add the old functions again, see

https://postgis.net/docs/PostGIS_FAQ.html#legacy_faq


EDIT

Second choice:

https://help.openstreetmap.org/questions/16175/nominatim-installation-problem-projection-code-failed

https://www.mail-archive.com/[email protected]/msg09334.html

comes with the same error, because the proj lib can not be found. This was a Windows system, but make sure osm2pgsql can find the proj lib.

6
  • I ran the legacy.sql command on the database (like this: psql -d osm -f /usr/local/Cellar/postgis/2.1.1/share/postgis/legacy.sql) and it still comes up with the same error. Apr 8, 2014 at 7:48
  • Does it fail with -m instead of -l too?
    – AndreJ
    Apr 8, 2014 at 8:11
  • No, it works fine with -m. But that puts the data in there in Mercator, which is no good. Apr 8, 2014 at 8:39
  • You could reproject the database after import if everything else fails. Can you run the tests on command line from the mailing list article I added to my question? Seems that proj is present, but can not be found.
    – AndreJ
    Apr 8, 2014 at 11:15
  • I ran the test and it produced the correct result, so it can't be the same issue they were having there... Apr 8, 2014 at 11:46
-1

AFAIK the most OSM tools rely on a 4326 projection, so it's not a wise idea to change the DB schema to a different one. Instead you could write a small wrapper or use e.g. Geoserver to reproject the geometries per request.

1
  • 1
    There's nothing wrong, EPSG:4326 is a equirectangular projection. Apr 8, 2014 at 7:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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