Skip to main content

RRaster

Simple and readable raster manipulation with Python.

This package is an attempt to create a set of user-friendly functions for reprojecting and manipulating rasters with Python. The syntax is meant to mirror that of the R Raster library.

Dependencies

  • Python 3.8+
  • numpy 1.3+
  • rasterio 1.2.6+
  • matplotlib 3.4.1+

Installation

It is recommended to use this package within a virtualenv.

$ python3 -m venv venv
$ source venv/bin/activate

# The RRaster package can be installed with pip
$ pip install rraster

# Alternatively, the development version of the package can be installed from 
$ pip install -r requirements.txt
$ pip install .

Examples

The current operations supported by RRaster are reprojection, reduction, writing to disk, and basic raster calculations (addition, subtraction, etc.). Below, a gridMet precipitation raster is projected to the EASE-2 grid and some basic manipulations are done. Although this syntax may be less Pythonic, I find it much easier to read and remember than the typical rasterio syntax.

import numpy as np
from pathlib import Path
import pkg_resources
from rraster.Raster import Raster, RasterStack

# Find path to data within the package
pth = Path(pkg_resources.resource_filename('rraster', 'data'))

# Read in rasters
r1 = Raster(pth / '19990601_pr.tif')
r1 = Raster(pth / 'template.tif')

# Reproject with one line of code
reproj = r1.reproject(r2, method='bilinear')

# Do some stuff to the new raster
reproj = reproj * r2 # Possible because the two rasters now share the same projection and resolution.
reproj /= 18

# Make a RasterStack 
stk = RasterStack(reproj, r2)
# Calculate the pixel-wise mean
new_raster = stk.reduce(np.mean, axis=0)

# Save the new raster to disk.
new_raster.write('./example.tif')

Release files for RRaster 0.0.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 RRaster 0.0.3
File Size Uploaded
RRaster-0.0.3.tar.gz 1.6 MB Details

Built distribution (wheel)

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

Total release size: 3.2 MB

Release files / RRaster-0.0.3.tar.gz

Download URL RRaster-0.0.3.tar.gz
Size 1.6 MB
Tags Source
SHA-256 checksum
How to use checksums
00a218c48c857a3c3d7220efffb1c80bef0326c09111158d1e5c78d9d55cd5a6
BLAKE2b-256 checksum
How to use checksums
3f8f4e67c499d3b78843a06cfd6a675e737e91fb382170eb71ebe38e8da6e803
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.5

Release files / RRaster-0.0.3-py3-none-any.whl

Download URL RRaster-0.0.3-py3-none-any.whl
Size 1.6 MB
Tags Python 3
SHA-256 checksum
How to use checksums
c33a69993805cec2c1686e9957a5a309b979d32f41825e9b394d189d67dce9be
BLAKE2b-256 checksum
How to use checksums
b4a6918ec572b1c62dae8482db74c316eccc653b0b9906746f0c2b458cb8b0d1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.5

Release history Release notifications | RSS feed

This release

0.0.3 This release

2 release files

0.0.2

2 release files

0.0.1

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