Skip to main content

A Python geospatial library for raster preprocessing, analysis, visualization, and modeling

Project description

Rasteric

Rasteric is a Python geospatial library designed for raster preprocessing, analysis, visualization, and modeling. It simplifies common GIS workflows with easy-to-use functions built on top of Rasterio and GeoPandas.

Installation

pip install rasteric

Dependencies are installed automatically:

  • rasterio
  • geopandas
  • shapely
  • numpy
  • pandas
  • matplotlib
  • scikit-learn
  • rasterstats
  • scipy (optional, for gap filling)

Requirements

  • Python >= 3.8

Supported Data Formats

  • Raster: GeoTIFF, TIFF
  • Vector: Shapefiles, GeoJSON
  • Tabular: CSV with spatial attributes (latitude/longitude)

Typical Use Cases

  • Satellite image preprocessing (Sentinel-2, Landsat)
  • NDVI and vegetation analysis
  • Land-use / land-cover mapping
  • Agricultural monitoring
  • Raster-vector data extraction
  • Geospatial machine learning data preparation
  • Time-series crop monitoring

Quick Start

from rasteric import plot, clip, ndvi, evi, stack, extract, mosaic, calc

# Visualize a raster with RGB bands
plot('sentinel2.tif', bands=(4, 3, 2), brightness_factor=4)

# Clip raster to study area
clip('raster.tif', 'boundary.shp', 'clipped.tif')

# Compute NDVI
ndvi('sentinel2.tif', 'ndvi_output.tif', red_band=3, nir_band=4)

# Compute Enhanced Vegetation Index
evi('sentinel2.tif', 'evi_output.tif', nir_band=4, red_band=3, blue_band=2)

# Stack band files into a single multi-band raster
stack('bands_folder/', 'stacked.tif')

# Merge tiles into one raster
mosaic('tiles/', 'merged.tif')

# Band math with custom expression
calc('(B8 - B4) / (B8 + B4)', inputs={'B8': 'nir.tif', 'B4': 'red.tif'}, output='ndvi.tif')

# Extract raster values at vector points
extract('raster.tif', 'points.shp', 'extracted.csv')

Functions

Vegetation Indices

Function Description
ndvi(raster_file, output_file, red_band, nir_band) Normalized Difference Vegetation Index
evi(raster_file, output_file, nir_band, red_band, blue_band) Enhanced Vegetation Index
savi(raster_file, output_file, nir_band, red_band, L) Soil-Adjusted Vegetation Index
ndwi(raster_file, output_file, green_band, swir_band) Normalized Difference Water Index
gndvi(raster_file, output_file, nir_band, green_band) Green NDVI (chlorophyll sensitivity)
ndmi(raster_file, output_file, nir_band, swir_band) Normalized Difference Moisture Index

Data Handling

Function Description
stack(input_folder, output_file) Stack multiple rasters into a single multi-band file
mosaic(input_folder, output_file, method) Merge raster tiles into one continuous raster
mergecsv(path, outfile) Merge all CSV files in a directory
clip(raster_file, shapefile, output_file) Clip a raster using a shapefile geometry
reproject(input_raster, output_raster, target_crs) Reproject a raster to a different CRS
resample(input_raster, output_raster, scale_factor) Resample raster to a new resolution

Raster Calculator

Function Description
calc(expression, inputs, output_file) Evaluate band math expression with named inputs
bandmath(input_file, equation, output_file) Evaluate band math using B1, B2, ... band numbers

Analysis

Function Description
zonalstats(raster_file, vector_file, stats) Zonal statistics for vector polygons
stats(raster_file) Basic raster statistics (min, max, mean, std)
fillnodata(input_raster, output_file) Fill NoData pixels via interpolation

Extraction

Function Description
extract(input_data, shp, output_csv) Extract raster values for vector features or CSV points
align_to_shp(input_tif, source_shp, output_tif) Reproject raster to match a shapefile's CRS

Visualization

Function Description
plot(file, bands, cmap, title, ax, brightness_factor) Display raster with band selection and brightness
contour(file) Overlay contour lines on a raster
hist(file, bin, title) Plot histogram of raster pixel values

Conversion

Function Description
convras(raster_file, output_shapefile) Convert raster to vector polygons

Utilities

Function Description
convpath(file_path) Convert backslashes to forward slashes
bandnames(input_raster, band_names) Update band descriptions
haversine(lon1, lat1, lon2, lat2) Great-circle distance between two points

Sentinel-2 Support

Rasteric includes dedicated Sentinel-2 processing functions:

from rasteric import process_sen2

# Convert JP2 to TIFF, resample bands, stack, and remove clouds
process_sen2('source_folder/', 'output_folder/')

Roadmap

v1.3 (planned)

  • change_detect() — Detect changes between two rasters
  • timeseries() — Time-series analysis of raster folder
  • cloudmask() — Cloud masking for Sentinel-2

v2.0 (planned)

  • classify() — Image classification (Random Forest, K-Means)
  • texture() — GLCM texture features
  • sample() — ML training data preparation

Contributing

We welcome contributions and issue reports!

License

MIT 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

rasteric-1.2.0.tar.gz (23.5 kB view details)

Uploaded Source

Built Distribution

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

rasteric-1.2.0-py3-none-any.whl (21.7 kB view details)

Uploaded Python 3

File details

Details for the file rasteric-1.2.0.tar.gz.

File metadata

  • Download URL: rasteric-1.2.0.tar.gz
  • Upload date:
  • Size: 23.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for rasteric-1.2.0.tar.gz
Algorithm Hash digest
SHA256 d402536b5a8a84e2bd46ec4cd52248c84d6e9e19f3ae0d4eed0b007bb97110eb
MD5 45e6e410fc1dc559028404efe20fc8d0
BLAKE2b-256 927df4a992b3fcbb22ba5f94bbba190c66b6235c8c23bd2be822df4d96bdfde9

See more details on using hashes here.

File details

Details for the file rasteric-1.2.0-py3-none-any.whl.

File metadata

  • Download URL: rasteric-1.2.0-py3-none-any.whl
  • Upload date:
  • Size: 21.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for rasteric-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d9cf685d84c65b01335be10fc2d551ea9578c40029d3895406ea46b5afcf2faa
MD5 a1fe83fc3ad362d4862d2884979ea900
BLAKE2b-256 776565e5bad86a1236abd80ce618820f32ca31a82360fba9a579df7bfc27a28d

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