Rasterio function wrappers for simple raster processing in Python that mimics the R Raster syntax.
Project description
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
Python3.8+numpy1.3+rasterio1.2.6+matplotlib3.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')
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 RRaster-0.0.3.tar.gz.
File metadata
- Download URL: RRaster-0.0.3.tar.gz
- Upload date:
- Size: 1.6 MB
- Tags: Source
- Uploaded using 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
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
00a218c48c857a3c3d7220efffb1c80bef0326c09111158d1e5c78d9d55cd5a6
|
|
| MD5 |
d3ecae4ccaa8418259beccb9020af297
|
|
| BLAKE2b-256 |
3f8f4e67c499d3b78843a06cfd6a675e737e91fb382170eb71ebe38e8da6e803
|
File details
Details for the file RRaster-0.0.3-py3-none-any.whl.
File metadata
- Download URL: RRaster-0.0.3-py3-none-any.whl
- Upload date:
- Size: 1.6 MB
- Tags: Python 3
- Uploaded using 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
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c33a69993805cec2c1686e9957a5a309b979d32f41825e9b394d189d67dce9be
|
|
| MD5 |
5a30ed24449857d288e763e4d40b7e56
|
|
| BLAKE2b-256 |
b4a6918ec572b1c62dae8482db74c316eccc653b0b9906746f0c2b458cb8b0d1
|