4

I am trying to use GDAL_Rasterize and found a link via Google that suggested that there were bugs in older versions.

I am running Ubuntu 14.04 LTS and 'gdalinfo --version' gives me 'GDAL 1.11.2, released 2015/02/10'

When I try 'sudo apt-get install python-gdal' I get the following:

Reading package lists... Done

Building dependency tree
Reading state information... Done python-gdal is already the newest version. The following packages were automatically installed and are no longer required: libqgis-analysis2.14.2 libqgis-analysis2.8.1 libqgis-app2.14.2 libqgis-core2.14.2 libqgis-core2.8.1 libqgis-gui2.14.2 libqgis-gui2.8.1 libqgis-networkanalysis2.14.2 libqgis-networkanalysis2.8.1 libqgis-server2.14.2 libqgis-server2.8.1 libqgisgrass2.8.1 libqgisgrass6-2.14.2 libqgispython2.14.2 libqgispython2.8.1 libsaga-api-2.2.6 libsaga-gdi-2.2.6 Use 'apt-get autoremove' to remove them. 0 to upgrade, 0 to newly install, 0 to remove and 9 not to upgrade. W: Duplicate sources.list entry http://ppa.launchpad.net/ubuntugis/ubuntugis-unstable/ubuntu/ trusty/main amd64 Packages (/var/lib/apt/lists/ppa.launchpad.net_ubuntugis_ubuntugis-unstable_ubuntu_dists_trusty_main_binary-amd64_Packages) W: Duplicate sources.list entry http://ppa.launchpad.net/ubuntugis/ubuntugis-unstable/ubuntu/ trusty/main i386 Packages (/var/lib/apt/lists/ppa.launchpad.net_ubuntugis_ubuntugis-unstable_ubuntu_dists_trusty_main_binary-i386_Packages) W: You may want to run apt-get update to correct these problems

Is there an easy fix for this?


I tried the fix at Installing gdal 1.9.0 on linux ubuntu server 10.04?

I editied it to look for the new release: wget ftp://ftp.remotesensing.org/gdal/CURRENT/gdal-2.1.0.tar.gz tar xvfz gdal-2.1.0.tar.gz cd gdal-2.1.0 ./configure --with-python make sudo make install

Now GDAL won't load at all. More worryingly Qgiswon't load either:


Couldn't load plugin 'processing'

ImportError: libgdal.so.20: cannot open shared object file: No such file or directory Traceback (most recent call last): File "/usr/lib/python2.7/dist-packages/qgis/utils.py", line 281, in loadPlugin import(packageName) File "/usr/lib/python2.7/dist-packages/qgis/utils.py", line 572, in _import mod = _builtin_import(name, globals, locals, fromlist, level) File "/usr/share/qgis/python/plugins/processing/init.py", line 29, in from processing.tools.general import * File "/usr/lib/python2.7/dist-packages/qgis/utils.py", line 572, in _import mod = _builtin_import(name, globals, locals, fromlist, level) File "/usr/share/qgis/python/plugins/processing/tools/general.py", line 28, in from processing.core.Processing import Processing File "/usr/lib/python2.7/dist-packages/qgis/utils.py", line 572, in _import mod = _builtin_import(name, globals, locals, fromlist, level) File "/usr/share/qgis/python/plugins/processing/core/Processing.py", line 48, in from processing.algs.qgis.QGISAlgorithmProvider import QGISAlgorithmProvider File "/usr/lib/python2.7/dist-packages/qgis/utils.py", line 572, in _import mod = _builtin_import(name, globals, locals, fromlist, level) File "/usr/share/qgis/python/plugins/processing/algs/qgis/QGISAlgorithmProvider.py", line 107, in from RasterLayerStatistics import RasterLayerStatistics File "/usr/lib/python2.7/dist-packages/qgis/utils.py", line 572, in _import mod = _builtin_import(name, globals, locals, fromlist, level) File "/usr/share/qgis/python/plugins/processing/algs/qgis/RasterLayerStatistics.py", line 36, in from processing.tools import raster File "/usr/lib/python2.7/dist-packages/qgis/utils.py", line 572, in _import mod = _builtin_import(name, globals, locals, fromlist, level) File "/usr/share/qgis/python/plugins/processing/tools/raster.py", line 30, in from osgeo import gdal File "/usr/lib/python2.7/dist-packages/qgis/utils.py", line 572, in _import mod = _builtin_import(name, globals, locals, fromlist, level) File "/usr/local/lib/python2.7/dist-packages/osgeo/init.py", line 21, in _gdal = swig_import_helper() File "/usr/local/lib/python2.7/dist-packages/osgeo/init.py", line 17, in swig_import_helper _mod = imp.load_module('_gdal', fp, pathname, description) ImportError: libgdal.so.20: cannot open shared object file: No such file or directory

Python version: 2.7.9 (default, Apr 2 2015, 15:39:13) [GCC 4.9.2] QGIS version: 2.14.1-Essen Essen, exported

Python Path: /usr/share/qgis/python /home/steve/.qgis2/python /home/steve/.qgis2/python/plugins /usr/share/qgis/python/plugins /usr/lib/python2.7 /usr/lib/python2.7/plat-i386-linux-gnu /usr/lib/python2.7/lib-tk /usr/lib/python2.7/lib-old /usr/lib/python2.7/lib-dynload /home/steve/.local/lib/python2.7/site-packages /usr/local/lib/python2.7/dist-packages /usr/lib/python2.7/dist-packages /usr/lib/python2.7/dist-packages/PILcompat /usr/lib/python2.7/dist-packages/gtk-2.0 /usr/lib/python2.7/dist-packages/wx-3.0-gtk2 /home/steve/.qgis2//python


SteveResearch
  • 291
  • 2
  • 14
  • OK I followed the ideas on http://gis.stackexchange.com/questions/21728/how-can-i-install-gdal-1-9-0-on-my-linux-ubuntu-server-10-04. Now I can'tload GDAL at all. What details would help diagnose that? – SteveResearch Jun 08 '16 at 09:20
  • You have to remove that new GDAL version, and re-install 1.11.2 – AndreJ Jun 08 '16 at 17:52
  • @AndreJ How do I reverse the process? sudo apt-get install build-essential python-all-dev wget http://download.osgeo.org/gdal/gdal-1.9.0.tar.gz tar xvfz gdal-1.9.0.tar.gz cd gdal-1.9.0 ./configure --with-python make sudo make install – SteveResearch Jun 08 '16 at 21:21
  • http://askubuntu.com/questions/1143/how-can-i-uninstall-software for both GDAL and QGIS (and maybe python-gdal as well). Then re-install QGIS 2.14.2 with all dependencies. – AndreJ Jun 09 '16 at 05:46

3 Answers3

2

I came to this question trying to use flag -makevalid or st_makevalid in the sql query, available since 3.1 (I was having 2.4), so just for using this function I didn't find a full system upgrade appealing; in GDAL I found the command, which needs an easy installatin of Miniconda:

$ conda install -c conda-forge gdal

$ ogrinfo --version GDAL 3.2.0, released 2020/10/26

And now this runs without error:

ogr2ogr -makevalid -f GPKG perimeters.gpkg perimeters.shp
- 'VirtualXPath'    [XML Path Language - XPath]
- 'VirtualXPath'    [XML Path Language - XPath]
Elio Diaz
  • 3,456
  • 9
  • 22
1

You have installed QGIS with ubuntugis support. https://launchpad.net/~ubuntugis/+archive/ubuntu/ubuntugis-unstable/+packages?field.name_filter=&field.status_filter=published&field.series_filter=trusty reveals that they only have GDAL 1.11.2 for trusty. The ubuntugis stable ppa does not offer a newer version for trusty either.

They offer however GDAL 2.1.0 for Ubuntu Xenial. So my best bet is to upgrade the operating system. GDAL is seldomly backported to older versions of Ubuntu.

Installing GDAL from a different source leads to unwanted trouble, if your version of QGIS is not compiled for that GDAL version. And I guess you don't want to compile QGIS from source to overcome that.

AndreJ
  • 76,698
  • 5
  • 86
  • 162
1

This will work (almost in 2022, with Ubuntu 20.04 and QGIS 3.22)

## Download GDAL v3.4.0 Source (ex. 3.4) 
## Build GDAL with ECW support (this will take a while...)
sudo wget http://download.osgeo.org/gdal/3.4.0/gdal340.zip
unzip gdal340.zip
cd gdal-3.4.0
./configure
sudo make clean && sudo make && sudo make install
César Arquero Cabral
  • 3,439
  • 1
  • 16
  • 53