Skip to main content

A Python package for augmenting geospatial raster data (GeoTIFFs) with various techniques including noise addition, patch mixing, and geometric transformations.

Project description

Geospectral

Overview

GeoSpectral is a high-performance multispectral image augmentation library designed for efficient geospatial data processing.

Features

  • Raster Clipping: Extract regions from large GeoTIFF files using shapefile boundaries
  • Multithreaded Support: Choose between threaded and non-threaded operations
  • Performance Optimized:
    • Non-threaded clipping: ~7 seconds
    • Multithreaded clipping: ~2 seconds (4x faster)
  • Automatic Worker Detection: Intelligent worker allocation based on system resources, or manual configuration

Getting Started

Import Packages

# Import Packages
from augmentation import clip_raster_threaded,clip_raster_serial
shape="data.shp"
tiff="data.tif"

)

Non-threaded clipping:

# Basic usage example
clip_raster_serial(
    shapefile_path=shape,
    tiff_file=tiff,
    output_dir="tiles",

)

Multithreaded clipping:

# Basic usage example
clip_raster_threaded(
    shapefile_path=shape,
    tiff_file=tiff,
    output_dir="tiles",

)

## Load filepaths after clipping

```python
filepath,filename=files_load("tiles")
print(filename)

This block of code will help to load all the absolute filepaths. It returns a tuple file location and file path.

Applying Augmentations

geometric_augmentations(
    image_path=filepath[0],
    aug_type=[],
    apply_all=True,
    noise=0.05,
    patchmix=True
)

This function provides a lot of features ranging from just simple geometric augmentation to a bit advanced features like adding gaussian noise ,applying patchmix .

Geometric Augmentations

This applies selected image transformations using NumPy:

  • H → Horizontal flip
  • V → Vertical flip
  • R → Rotate 90°
  • R2 → Rotate 180°
  • R3 → Rotate 270°

You can pass specific augmentations in a list using aug_type (e.g., ["H", "R"]) and set apply_all=False to apply only those operations.

Set apply_all=True to apply all augmentations.


Gaussian Noise Augmentation

You can add Gaussian noise to the image by simply passing a noise value (e.g., noise=0.05) when calling geometric_augmentations.

Example:

geometric_augmentations(
    image_path=filepath[0],
    aug_type=[],
    apply_all=True,
    noise=0.05,
    patchmix=True
)

How it works:

  • The GeoTIFF bands are optionally normalized to the range [0, 1]
  • Random Gaussian noise is generated using the provided noise value as the standard deviation
  • Noise is added to each pixel across all bands
  • Values are clipped to keep them within valid range
  • The noisy image is saved as a new GeoTIFF


PatchMix (patchmix=True)

PatchMix replaces one quadrant of the clean image with its noisy version to create hybrid samples. The image is split into four parts (top-left, top-right, bottom-left, bottom-right), and noise is inserted into one patch at a time.

File Naming

The output files show where noise was added:

  • noise_tl.tif → top-left
  • noise_tr.tif → top-right
  • noise_bl.tif → bottom-left
  • noise_br.tif → bottom-right

This helps models learn localized noise and improves robustness.


Run Locally

Clone the project:

git clone https://github.com/bdipesh3045/geospectral.git
cd geospectral

Install dependency:

pip install setuptools

Install the package:

pip install .

Thank you!


Thank you for using GeoSpectral! 🎉 If you have any questions or feedback, feel free to reach out at 📧 dipeshsharma9800@gmail.com


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

geospectral-0.2.3.tar.gz (8.2 kB view details)

Uploaded Source

Built Distribution

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

geospectral-0.2.3-py3-none-any.whl (7.8 kB view details)

Uploaded Python 3

File details

Details for the file geospectral-0.2.3.tar.gz.

File metadata

  • Download URL: geospectral-0.2.3.tar.gz
  • Upload date:
  • Size: 8.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.3

File hashes

Hashes for geospectral-0.2.3.tar.gz
Algorithm Hash digest
SHA256 6bbaefc3e5733fd01f839b2984439e629a361a2ca21e6816d998e624a392868e
MD5 bc254ec86c63b6adfce59c5a796e638b
BLAKE2b-256 52f63601e5facefa8c6576259fc560c0adbbda4a7b708c43dc110552af1a8e9c

See more details on using hashes here.

File details

Details for the file geospectral-0.2.3-py3-none-any.whl.

File metadata

  • Download URL: geospectral-0.2.3-py3-none-any.whl
  • Upload date:
  • Size: 7.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.3

File hashes

Hashes for geospectral-0.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 5925c67c27e63f92d03f3eba8561fd37f692fe6f11d881ff5db98b452f2b601b
MD5 ccbbb024025588117050a956cc57f443
BLAKE2b-256 8a5dc4f23d526a23cb252f0ec737c7e81b802b647ec3e8f28a9d6aeb984bef2e

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