Skip to main content

rasterra

PyPI PyPI - Python Version PyPI - License


Documentation: https://collijk.github.io/rasterra

Source Code: https://github.com/collijk/rasterra

PyPI: https://pypi.org/project/rasterra/


An in-memory object-oriented raster manipulation library.

rasterra is a library for manipulating raster data in memory. It is designed to be used in lieu of rasterio to allow for easier manipulation of raster data. It is designed to be used in conjunction with geopandas when vector data is also being used.

Currently, rasterra is in a very early stage of development. It's primary limitation at this point is that it only supports single-band raster data. Multi-band support is planned for the near future.

Installation

pip install rasterra

Usage

File I/O

Reading and writing raster data is done using the load_raster and to_file functions.

import rasterra as rt

# Read in a raster
raster = rt.load_raster("path/to/raster.tif")

# Write a raster to disk
raster.to_file("path/to/output.tif")

A raster can also be read and mosaic'd from multiple files using the load_mf_raster function.

import rasterra as rt

# Read in a multi-file raster
raster = rt.load_mf_raster(["path/to/raster1.tif", "path/to/raster2.tif"])

Raster Manipulation

rasterra provides a number of methods for manipulating raster data. These methods are designed to be used in a method-chaining style, similar to pandas and geopandas.

import rasterra as rt
import geopandas as gpd

# Read in a raster
raster = rt.load_raster("path/to/raster.tif")
shapes = gpd.read_file("path/to/polygons.shp")


new_raster = (
    raster
    .to_crs(shapes.crs)          # Reproject the raster to the same CRS as the polygons
    .clip(shapes)                # Clip the raster to the bounding box of the polygons
    .mask(shapes, fill_value=0)  # Mask the raster to the polygons, filling in areas outside the polygons with 0
    .resample(0.5, 'sum')        # Downsample the raster half the original resolution,
                                 # computing the area-weighted sum of the contributing pixels
)

Metadata

Release files for rasterra 0.6.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for rasterra 0.6.3
File Size Uploaded
rasterra-0.6.3.tar.gz 14.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for rasterra 0.6.3
File Interpreter ABI Platform
rasterra-0.6.3-py3-none-any.whl Python 3 none any Details

Total release size: 29.3 kB

Release files / rasterra-0.6.3.tar.gz

Download URL rasterra-0.6.3.tar.gz
Size 14.4 kB
Tags Source
SHA-256 checksum
How to use checksums
a7ca63aa50c5a13c1091b300d2ebdfb81e28429cf959ddb064a4d0998c5672d5
BLAKE2b-256 checksum
How to use checksums
55f9f53340bed79e90c1c454b947751f9c3f1973fb8ea54920066c123aff12bb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.1.3 CPython/3.12.10 Linux/6.11.0-1014-azure

Release files / rasterra-0.6.3-py3-none-any.whl

Download URL rasterra-0.6.3-py3-none-any.whl
Size 14.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
645c269b02ebe950d6abef7a6e11bfa68d6446329b199137261b6a2d0ef83f88
BLAKE2b-256 checksum
How to use checksums
56e65e648f55054e2521adacfbc55938fe85b69ab58bf0e76587f2dfbf653563
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.1.3 CPython/3.12.10 Linux/6.11.0-1014-azure

Release history Release notifications | RSS feed

This release

0.6.3 This release

2 release files

0.6.2

2 release files

0.6.1

2 release files

0.6.0

2 release files

0.5.14

2 release files

0.5.12

2 release files

0.5.11

2 release files

0.5.10

2 release files

0.5.9

2 release files

0.5.8

2 release files

0.5.7

2 release files

0.5.6

2 release files

0.5.5

2 release files

0.5.3

2 release files

0.5.2

2 release files

0.5.1

2 release files

0.5.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page