Skip to main content

GDAR - The Generic Data Raster

Project description

GDAR - The Generic Data Raster

What is GDAR?

GDAR — the Generic Data Raster — is a Python library for working with gridded geospatial data. Its central abstraction is the DataRaster, which combines a data source with metadata describing the grid the data lives on (shape, origin, sample spacing, coordinate reference system) and the meaning of its values (data type, nodata sentinel, units). The data source can be a NumPy-like array already in memory, a file read on demand, or a get_data() callable that computes the necessary subset of the data when invoked. That last option gives DataRaster pull semantics: an entire processing chain can be assembled in which intermediate steps are neither written to disk nor ever materialised in their entirety — data is produced only for the regions that downstream consumers actually request. Once data is wrapped in a DataRaster, operations that would otherwise require juggling separate geotransforms, masks, and projection strings — indexing by physical coordinates, resampling onto another grid, cropping, reading and writing native file formats — become straightforward method calls that keep the spatial bookkeeping in sync with the pixel data.

A companion abstraction, the Collection, groups multiple related DataRasters that belong together — for example time slices of a dataset, bands from a multispectral instrument, or polarimetric channels from a SAR acquisition.

gdar-base is the core of the library and has deliberately few dependencies: NumPy, with optional extras for plotting (matplotlib) and map-projection support. It forms the foundation for a family of companion packages that build on the same DataRaster abstraction:

  • gdar-crs — coordinate reference systems and map projections
  • gdar-orbit — satellite orbit propagation and geometry
  • gdar-sar — synthetic-aperture radar processing primitives
  • gdar-optical — remotely-sensed optical data
  • gafa — geometry- and frequency-agnostic SAR focusing and simulation

GDAR is developed at NORCE and used in production SAR/InSAR processing chains, including InSAR Norge, Norway's national ground-deformation monitoring service developed by NORCE based on GDAR and its precursor GSAR. The core raster machinery is domain-agnostic, however, and equally applicable to any gridded dataset — elevation models, classification maps, time-series stacks, and so on.

Installation

Install from PyPI:

pip install gdar-base

or with uv:

uv pip install gdar-base

Optional extras:

  • crs — map projections (requires GDAL, see below)
  • plotting — matplotlib
  • interactive — IPython
pip install "gdar-base[crs,plotting]"

GDAL dependency

GDAL is not required by gdar-base itself, but several downstream packages (notably gdar-crs) need it. Since geocoding depends on gdar-crs, many SAR processing workflows will need GDAL.

Packages that depend on GDAL (including gdar-base[crs]) require the system GDAL library to be installed separately.

Ubuntu

Installing GDAL

Make sure to install both gdal-bin and libgdal-dev packages.

MacOS

Install using Homebrew:

brew install gdal

Verifying the installation

After installing GDAL, you should be able to run ogrinfo --version from your shell and see output like GDAL 3.12.3 "Chicoutimi", released 2026/03/17 (debug build).

Installing the GDAL Python bindings

Pin the Python bindings to the matching system GDAL version:

uv pip install numpy setuptools
uv pip install --no-build-isolation "gdal==$(gdal-config --version)"

Both numpy and setuptools must be installed first because the GDAL Python bindings build requires them. The --no-build-isolation flag is needed because of this issue.

Development

Installing from the NORCE GitLab registry

Internal users and contributors can install pre-release versions from the NORCE GitLab package registry. Two token types are supported:

  • opengdar deploy token: From the earth-observation/opengdar group page in GitLab, go to Settings → Repository → Deploy Tokens and create a token with the read_package_registry scope. Note the auto-assigned username (e.g. gitlab+deploy-token-42).
  • Personal access token: Create a new access token in GitLab with the read_api scope. The username for personal tokens is __token__.

Installing with pip

pip install gdar-base \
    --index-url https://<username>:<token>@gitlab.norceresearch.no/api/v4/groups/523/-/packages/pypi/simple

Replace <username> and <token> with the credentials from the previous step (e.g. gitlab+deploy-token-48 and the token value, or __token__ and a personal access token).

Installing with uv

Add gdar-base to your project's dependency list and configure the index in pyproject.toml:

[tool.uv]
no-build-isolation-package = ["gdal"]

[[tool.uv.index]]
name = "opengdar"
url = "https://gitlab.norceresearch.no/api/v4/groups/523/-/packages/pypi/simple"
explicit = true

[tool.uv.sources]
gdar-base = { index = "opengdar" }

The index section tells uv where to find gdar packages. With explicit = true, only packages listed in [tool.uv.sources] are fetched from that index; everything else comes from PyPI.

Set the following environment variables to authenticate:

# bash / zsh — for deploy tokens:
export UV_INDEX_OPENGDAR_USERNAME="gitlab+deploy-token-NN"
export UV_INDEX_OPENGDAR_PASSWORD="<deploy_token>"

# or for personal access tokens:
export UV_INDEX_OPENGDAR_USERNAME="__token__"
export UV_INDEX_OPENGDAR_PASSWORD="<personal_token>"

Then sync your environment:

uv sync --extra crs --extra plotting --extra interactive

A sample-pyproject.toml with the full configuration is included in the repository.

Creating container images

The easiest way to build an image with gdar installed is to start from one with a sufficiently recent Python preinstalled, along with GDAL and its Python bindings.

One good source for base images is OSGeo/gdal on GitHub.

Dockerfile and pyproject.toml examples for building a custom image with GDAR are provided in this snippet.

Building behind the NORCE firewall (with NORCE SSL certs)

  1. Place the Dockerfile and pyproject.toml files in the project root.
  2. Export the SSL certs:
    security find-certificate -p -c 'Norwegian Research Centre Root CA' \
        /Library/Keychains/System.keychain > ca-certificates.crt
    
  3. Build:
    docker build \
        --secret id=opengdar-token,env=UV_INDEX_OPENGDAR_PASSWORD \
        --secret id=ca-certificates,src=ca-certificates.crt \
        -t <tag> .
    

Building without extra certs

Remove lines 4-6 in Dockerfile to disable extra SSL certs, then:

docker build \
    --secret id=opengdar-token,env=UV_INDEX_OPENGDAR_PASSWORD \
    -t <tag> .

Internal links

License

This project is licensed under the Apache License, Version 2.0. You may obtain a copy of the license at https://www.apache.org/licenses/LICENSE-2.0 or in the LICENSE file distributed with this source.

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Project details


Download files

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

Source Distribution

gdar_base-1.2.0.post2.tar.gz (147.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gdar_base-1.2.0.post2-py3-none-any.whl (140.7 kB view details)

Uploaded Python 3

File details

Details for the file gdar_base-1.2.0.post2.tar.gz.

File metadata

  • Download URL: gdar_base-1.2.0.post2.tar.gz
  • Upload date:
  • Size: 147.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.8 {"installer":{"name":"uv","version":"0.10.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for gdar_base-1.2.0.post2.tar.gz
Algorithm Hash digest
SHA256 7a023a459ef8fb4ced038058921592c245e0dbef8c66f94ddb8bcfe6734d300f
MD5 5b3f8b3ac6afc24cfa43256269d46d94
BLAKE2b-256 179e0c6ea49ef5b03c0906efae07c4752573e7e537f6e24d10790e5077f3cac1

See more details on using hashes here.

File details

Details for the file gdar_base-1.2.0.post2-py3-none-any.whl.

File metadata

  • Download URL: gdar_base-1.2.0.post2-py3-none-any.whl
  • Upload date:
  • Size: 140.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.8 {"installer":{"name":"uv","version":"0.10.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for gdar_base-1.2.0.post2-py3-none-any.whl
Algorithm Hash digest
SHA256 f26a619cba0650066eabdf7428c99208a57420be5f45ce3a086a9b208e6545dc
MD5 5271ee30c31feca71b0bede73ca17b67
BLAKE2b-256 3c9427ef0a9c0a8ef320c8206f704fea2b05fe3d38d9b122a4df68971706d39a

See more details on using hashes here.

Supported by

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