17

I solved the library problem, but others remain, only vaguely related to that of PROJ.4 libraries are not loaded. I asked a follow-up question for these.

My GDAL package and PROJ.4 library are damaged, which causes errors while trying to reproject files (see old question below). I don't know whether this problem started while I mistakenly installed another instance of GDAL or before; however, I've uninstalled it and reinstalled QGIS and the problem remains.

After each reinstall, QGIS has the same plugins as before, so the part causing the errors is left untouched by the install/uninstall process.

What have I tried:

  • sudo apt-get remove build-essential python-all-dev and sudo apt-get remove gdal-bin to purge the manually installed GDAL
  • (un)install of QGIS with Ubuntu Software Center
  • sudo apt-get --purge autoremove
  • dpkg -l | grep '^rc' | awk '{print $2}' | sudo xargs dpkg --purge and dpkg --list | grep "^rc" | cut -d " " -f 3 | xargs sudo dpkg --purge to purge the configuration files

Still no luck. I've found something that seemed related, but that's for Windows, not for my Ubuntu 14.04. What else (and how) should I purge before next install of QGIS?


The original question:

I try to reproject some shapefiles with ogr2ogr. However, I always get the following error:

ERROR 6: Unable to load PROJ.4 library (libproj.so), creation of
OGRCoordinateTransformation failed.
Failed to create coordinate transformation between the
following coordinate systems.  This may be because they
are not transformable, or because projection services
(PROJ.4 DLL/.so) could not be loaded.

I tested this with various transformations, including such basic combinations as from WGS84 (EPSG:4326) to UTM (EPSG:3857), and this error occurs all the time.

The problem might be caused by the fact that although I have GDAL with my QGIS (2.10), I mistakenly installed it once more (from the source, doing it as this answer suggested).

After facing this problem a few times, I tried to uninstall the new GDAL instance (sudo apt-get remove build-essential python-all-dev and sudo apt-get remove gdal-bin - not sure whether it is cleanly removed or not).

In /USR/LIB/ I have libproj.so.0 and libproj.so.0.7.0, not libproj.so. I can't see it even with hidden files shown. However, when I try ln -s libproj.so.0.7.0 libproj.so (or the same with sudo), it complains that libproj.so already exists.

6
  • It might help to remove and reinstall qgis as well.
    – AndreJ
    Commented Aug 5, 2015 at 7:06
  • @AndreJ: reinstalled and nothing changed. However, the associated files seem untouched (I have the same plugins as before QGIS reinstall etc.), so I'll try to remove it completely now.
    – Pavel V.
    Commented Aug 5, 2015 at 7:24
  • I think you should edit the title and tags. Your issue is an installation problem and you might want to ask how to correct a broken installation.
    – user30184
    Commented Aug 5, 2015 at 8:07
  • @user30184: editted, as you suggested.
    – Pavel V.
    Commented Aug 5, 2015 at 9:09
  • 2
    That error message does seem to indicate that libproj isn't being loaded. Although the packages should have done it already, have you run sudo ldconfig? Also, does the output of ldd ogrinfo (you may have to give the full path for ogrinfo) show libproj.so and is it in the directory you expected (/usr/lib)? Commented Aug 5, 2015 at 11:04

5 Answers 5

15

In https://gis.stackexchange.com/questions/158457/gdal2tiles-how-to-make-filenames-of-tiles-to-represent-xyz-coordinates, somebody mentions doing:

sudo ln -s /usr/lib/libproj.so.0 /usr/lib/libproj.so

Which absolutely fixed the same error (ERROR 6: Unable to load PROJ.4 library (libproj.so)) for me.


On the x86_64 architecture you may need to use this variation:

sudo ln -s /usr/lib64/libproj.so.0 /usr/lib/libproj.so
2
  • 1
    This solved it for me, And I was doing my head in trying to find it by the filename in the error, while its called libproj.so.0
    – ekerner
    Commented Mar 6, 2017 at 16:41
  • 1
    I needed to symlink both libproj and gdal and with different numbers — i.e. ln -s /usr/lib/libproj.so.15 /usr/lib/libproj.so; ln -s /usr/lib/libgdal.so.20 /usr/lib/libgdal.so but working for me now, thanks for the steer! Commented Jul 5, 2019 at 8:18
12

After several wrong ways, including multiple reinstall of libproj0 package and even installing QGIS from sources different from the Ubuntu Software Center default (I think it's from the official QGIS repository - http://qgis.org/debian trusty main), I understood how to apply advice by @EvilGenius: ldd ogrinfo didn't show libproj no matter how many times I used sudo ldconfig, until I typed:

export LD_LIBRARY_PATH=/lib:/usr/lib:/usr/local/lib

Since then, the library is read normally.

2
  • Unfortunately, it didn't work for me. If you could help me here is the question: stackoverflow.com/q/67133013/4300670 Commented May 11, 2021 at 22:28
  • @AlitonOliveira: unfortunately, I left the work with QGIS five years ago, so I don't know.
    – Pavel V.
    Commented May 12, 2021 at 13:29
9

Try:

sudo apt-get install libproj-dev

It solved the same error for me when using gdal_translate for extracting bands from an hdf image.

0

use --with-static-proj when compiling gdal libraries.

1
  • 1
    It would be useful to include a bit of an explanation along with your answer
    – Midavalo
    Commented May 13, 2016 at 8:23
0

You may be missing proj-devel in the case of Fedora. On Ubuntu this may have a different name such as libproj-dev

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.