Tuesday 6 June 2017

installation - Repairing broken GDAL and PROJ.4 on Ubuntu?


I solved the library problem, but others remain, only vaguely related to that of PROJ.4 library 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 source, doing it as this answer suggested).



After facing this problem 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.



Answer



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.


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...