Skip to main content

GDAL: Geospatial Data Abstraction Library

Project description

This Python package and extensions are a number of tools for programming and manipulating the GDAL Geospatial Data Abstraction Library.

The GDAL project maintains SWIG generated Python bindings for GDAL/OGR. Generally speaking the classes and methods mostly match those of the GDAL and OGR C++ classes. There is no Python specific reference documentation, but the https://gdal.org/api/python_bindings.html#tutorials includes Python examples.

Dependencies

  • libgdal (3.8.1 or greater) and header files (gdal-devel)

  • numpy (1.0.0 or greater) and header files (numpy-devel) (not explicitly required, but many examples and utilities will not work without it)

Installation

Conda

GDAL can be quite complex to build and install, particularly on Windows and MacOS. Pre built binaries are provided for the conda system:

https://docs.conda.io/en/latest/

By the conda-forge project:

https://conda-forge.org/

Once you have Anaconda or Miniconda installed, you should be able to install GDAL with:

conda install -c conda-forge gdal

Unix

The GDAL Python bindings requires setuptools.

pip

GDAL can be installed from the Python Package Index:

pip install GDAL

It will be necessary to have libgdal and its development headers installed if pip is expected to do a source build because no wheel is available for your specified platform and Python version.

To install the version of the Python bindings matching your native GDAL library:

pip install GDAL=="$(gdal-config --version).*"

Building as part of the GDAL library source tree

Python bindings are generated by default when building GDAL from source. For more detail, see Python bindings options

The GDAL Python package is built using SWIG. The currently supported version is SWIG >= 4

Usage

Imports

There are five major modules that are included with the GDAL Python bindings.:

>>> from osgeo import gdal
>>> from osgeo import ogr
>>> from osgeo import osr
>>> from osgeo import gdal_array
>>> from osgeo import gdalconst

API

API documentation is available at https://gdal.org/api/python/osgeo.html

Numpy

One advanced feature of the GDAL Python bindings not found in the other language bindings is integration with the Python numerical array facilities. The gdal.Dataset.ReadAsArray() method can be used to read raster data as numerical arrays, ready to use with the Python numerical array capabilities.

Tutorials

See https://gdal.org/api/python_bindings.html#tutorials

Gotchas

Although GDAL’s and OGR’s Python bindings provide a fairly “Pythonic” wrapper around the underlying C++ code, there are several ways in which the Python bindings differ from typical Python libraries. These differences can catch Python programmers by surprise and lead to unexpected results. These differences result from the complexity of developing a large, long-lived library while continuing to maintain backward compatibility. They are being addressed over time, but until they are all gone, please review this list of https://gdal.org/api/python_gotchas.html

Examples

One example of GDAL/numpy integration is found in the val_repl.py script.

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

GDAL-3.8.1.tar.gz (802.3 kB view details)

Uploaded Source

File details

Details for the file GDAL-3.8.1.tar.gz.

File metadata

  • Download URL: GDAL-3.8.1.tar.gz
  • Upload date:
  • Size: 802.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.8.1 requests/2.25.1 setuptools/60.0.0 requests-toolbelt/0.8.0 tqdm/4.30.0 CPython/3.8.10

File hashes

Hashes for GDAL-3.8.1.tar.gz
Algorithm Hash digest
SHA256 92bab022810bf7e218cfc15cdd58f100b2f15b81bba24e12bb156d67c707bbb3
MD5 f0e54ff3742907be948eed6f7a86568d
BLAKE2b-256 00bce7a8bddd6840e9862b7cc4f75ca485ecd06e20bd36f64ba7c1c62f1794b8

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page