[GIS] Installing GDAL/ogr2ogr in Ubuntu 18.04 returning Unmet dependency erorr

gdalUbuntu

I am trying to install GDAL in Ubuntu 18.04 with the following commands

sudo add-apt-repository -y ppa:ubuntugis/ppa
sudo apt update
sudo apt install gdal-bin python-gdal python3-gdal

But it returning the following error

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 gdal-bin : Depends: gdal-abi-2-4-0
            Depends: libgdal20 (>= 2.4.0) but it is not going to be installed
 python-gdal : Depends: python-numpy (>= 1:1.13.1) but it is not installable
               Depends: python-numpy-abi9 but it is not installable
               Depends: gdal-abi-2-4-0
               Depends: libgdal20 (>= 2.4.0) but it is not going to be installed
 python3-gdal : Depends: python3-numpy (>= 1:1.13.1) but it is not installable
                Depends: python3-numpy-abi9 but it is not installable
                Depends: gdal-abi-2-4-0
                Depends: libgdal20 (>= 2.4.0) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

Best Answer

I recently started using a ubuntu-based container: image 18.04 (server) and standard package repository in apt's sources.list.

After running this container and searching for packages using the standard commands:

  • apt-get update
  • apt-cache search

I found GDAL and Python GDAL as results for the following commands:

apt-cache search gdal | grep -i ogr

  • dans-gdal-scripts - GDAL contributed tools by Geographic Information Network of Alaska
  • gdal-bin - Geospatial Data Abstraction Library - Utility programs

apt-cache search gdal |grep -i python

  • python-gdal - Python bindings to the Geospatial Data Abstraction Library
  • python3-gdal - Python 3 bindings to the Geospatial Data Abstraction Library

Next, I installed the related GDAL apt-get install gdal-bin package and tested the following command to import a GeoJSON into a PostGIS database.

/usr/bin/ogr2ogr -f "PostgreSQL" PG:"dbname='the_database_name' host='my_ip_or_hostname' port='5432' user='an_user' password='my_secret_pass'" one_geojson_file.json -lco GEOMETRY_NAME=geometries -nln output_table_name

I haven't tested the Python package to see if it's working, but the installation went without errors.

apt-get install python3-gdal

Additional information about O.S.

Command output cat /etc/os-release

  NAME="Ubuntu"
  VERSION="18.04.4 LTS (Bionic Beaver)"
  ID=ubuntu
  ID_LIKE=debian
  PRETTY_NAME="Ubuntu 18.04.4 LTS"
  VERSION_ID="18.04"
  HOME_URL="https://www.ubuntu.com/"
  SUPPORT_URL="https://help.ubuntu.com/"
  BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
  PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
  VERSION_CODENAME=bionic
  UBUNTU_CODENAME=bionic