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 flipV→ Vertical flipR→ 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
noisevalue 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-leftnoise_tr.tif→ top-rightnoise_bl.tif→ bottom-leftnoise_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
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 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6bbaefc3e5733fd01f839b2984439e629a361a2ca21e6816d998e624a392868e
|
|
| MD5 |
bc254ec86c63b6adfce59c5a796e638b
|
|
| BLAKE2b-256 |
52f63601e5facefa8c6576259fc560c0adbbda4a7b708c43dc110552af1a8e9c
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5925c67c27e63f92d03f3eba8561fd37f692fe6f11d881ff5db98b452f2b601b
|
|
| MD5 |
ccbbb024025588117050a956cc57f443
|
|
| BLAKE2b-256 |
8a5dc4f23d526a23cb252f0ec737c7e81b802b647ec3e8f28a9d6aeb984bef2e
|