Abstraction of gdal datasets for doing basic math operations
Project description
Yirgacheffe: a declarative geospatial library for Python to make data-science with maps easier
Overview
Yirgacheffe is a declarative geospatial library, allowing you to operate on both raster and polygon geospatial datasets without having to do all the tedious book keeping around layer alignment or dealing with hardware concerns around memory or parallelism. you can load into memory safely.
Example common use-cases:
- Do the datasets overlap? Yirgacheffe will let you define either the intersection or the union of a set of different datasets, scaling up or down the area as required.
- Rasterisation of vector layers: if you have a vector dataset then you can add that to your computation and yirgaceffe will rasterize it on demand, so you never need to store more data in memory than necessary.
- Do the raster layers get big and take up large amounts of memory? Yirgacheffe will let you do simple numerical operations with layers directly and then worry about the memory management behind the scenes for you.
- Parallelisation of operations over many CPU cores.
- Built in support for optionally using GPUs via MLX support.
Installation
Yirgacheffe is available via pypi, so can be installed with pip for example:
$ pip install yirgacheffe
Documentation
The documentation can be found on yirgacheffe.org
Simple examples:
Here is how to do cloud removal from Sentinel-2 data, using the Scene Classification Layer data:
import yirgaceffe as yg
with (
yg.read_raster("T37NCG_20250909T073609_B06_20m.jp2") as vre2,
yg.read_raster("T37NCG_20250909T073609_SCL_20m.jp2") as scl,
):
is_cloud = (scl == 8) | (scl == 9) | (scl == 10) # various cloud types
is_shadow = (scl == 3)
is_bad = is_cloud | is_shadow
masked_vre2 = yg.where(is_bad, float("nan"), vre2)
masked_vre2.to_geotiff("vre2_cleaned.tif")
or a species' Area of Habitat calculation:
import yirgaceffe as yg
with (
yg.read_raster("habitats.tif") as habitat_map,
yg.read_raster('elevation.tif') as elevation_map,
yg.read_shape('species123.geojson') as range_map,
):
refined_habitat = habitat_map.isin([...species habitat codes...])
refined_elevation = (elevation_map >= species_min) && (elevation_map <= species_max)
aoh = refined_habitat * refined_elevation * range_polygon * area_per_pixel_map
print(f'Area of habitat: {aoh.sum()}')
Thanks
Thanks to discussion and feedback from my colleagues, particularly Alison Eyres, Patrick Ferris, Amelia Holcomb, and Anil Madhavapeddy.
Inspired by the work of Daniele Baisero in his AoH library.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file yirgacheffe-1.9.3.tar.gz.
File metadata
- Download URL: yirgacheffe-1.9.3.tar.gz
- Upload date:
- Size: 69.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6ae21f27fc27d94cf75eff0803b09c959b9e12ecece9c544a72b4adbe116bc59
|
|
| MD5 |
d248843c6850959f476a9b5e197dc396
|
|
| BLAKE2b-256 |
c13be598b7853ee4e99866aab8fd10f26427026238a7a16c8999b9131a92bea3
|
File details
Details for the file yirgacheffe-1.9.3-py3-none-any.whl.
File metadata
- Download URL: yirgacheffe-1.9.3-py3-none-any.whl
- Upload date:
- Size: 47.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e20cf73d40675be1c94e4f3c2ce9d0490e91fb379aa531436d4792b8a59e403f
|
|
| MD5 |
76004d7539c84d3b75b18a47ca8de713
|
|
| BLAKE2b-256 |
854395dacf0fb60a9aeaf278f1074f449279ac8a9460eb5651dc1a8e35400048
|