OxiGDAL Python Bindings
Python bindings for OxiGDAL, a pure Rust geospatial data abstraction library. OxiGDAL provides high-performance geospatial operations with seamless NumPy integration.
Features
- Pure Rust Performance: Leverages Rust's speed and safety
- NumPy Integration: Zero-copy data transfer where possible
- Raster Operations: Read/write GeoTIFF, Zarr, NetCDF, and more
- Vector Operations: GeoJSON support with geometry operations
- Raster Calculator: Algebraic expressions on raster data
- Coordinate Transformations: Reprojection and warping
- Type Hints: Full type stub support for IDEs
- No External Dependencies: No GDAL installation required
Installation
From PyPI (recommended)
pip install oxigdal
From Source
# Install maturin
pip install maturin
# Build and install
cd crates/oxigdal-python
maturin develop --release
Quick Start
Reading Rasters
import oxigdal
import numpy as np
# Open a raster file
ds = oxigdal.open("input.tif")
# Get metadata
print(f"Size: {ds.width}x{ds.height}")
print(f"Bands: {ds.band_count}")
# Read a band as NumPy array
band1 = ds.read_band(1)
print(band1.shape, band1.dtype)
# Get full metadata
metadata = ds.get_metadata()
print(metadata)
# Close dataset
ds.close()
Writing Rasters
import oxigdal
import numpy as np
# Create test data
data = np.random.rand(512, 512).astype(np.float32)
# Create a new raster
ds = oxigdal.create_raster(
"output.tif",
width=512,
height=512,
bands=1,
dtype="float32",
crs="EPSG:4326",
nodata=-9999.0
)
# Write data
ds.write_band(1, data)
# Set metadata
ds.set_metadata({
"crs": "EPSG:4326",
"nodata": -9999.0
})
# Close
ds.close()
Using Context Manager
import oxigdal
import numpy as np
# Automatically closes the dataset
with oxigdal.open("input.tif") as ds:
data = ds.read_band(1)
print(f"Mean: {data.mean():.2f}")
Raster Calculator
import oxigdal
import numpy as np
# Open multi-band image
ds = oxigdal.open("sentinel2.tif")
red = ds.read_band(3) # Red band
nir = ds.read_band(4) # NIR band
# Calculate NDVI using algebraic expression
ndvi = oxigdal.calc(
"(NIR - RED) / (NIR + RED)",
NIR=nir,
RED=red
)
# More complex expressions
evi = oxigdal.calc(
"2.5 * (NIR - RED) / (NIR + 6 * RED - 7.5 * BLUE + 1)",
NIR=nir,
RED=red,
BLUE=ds.read_band(2)
)
# Simple arithmetic
scaled = oxigdal.calc("A * 0.0001 - 0.1", A=red)
Reprojection
import oxigdal
# Reproject to Web Mercator
oxigdal.warp(
"input.tif",
"output_3857.tif",
dst_crs="EPSG:3857",
resampling="bilinear"
)
# Resize raster
oxigdal.warp(
"input.tif",
"output_resized.tif",
width=1024,
height=1024,
resampling="cubic"
)
# Reproject and resize
oxigdal.warp(
"input.tif",
"output.tif",
dst_crs="EPSG:4326",
width=2048,
height=2048,
resampling="lanczos"
)
Vector Operations
import oxigdal
# Read GeoJSON
features = oxigdal.read_geojson("input.geojson")
print(f"Features: {len(features['features'])}")
# Buffer a geometry
point = {
"type": "Point",
"coordinates": [0.0, 0.0]
}
buffered = oxigdal.buffer_geometry(point, distance=100.0)
# Write GeoJSON
output = {
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"geometry": buffered,
"properties": {"name": "Buffered Point"}
}
]
}
oxigdal.write_geojson("output.geojson", output, pretty=True)
API Reference
Core Functions
open(path: str, mode: str = "r") -> Dataset
Opens a geospatial dataset.
Parameters:
path: Path to file (local or remote URL)mode: Open mode - "r" for read (default), "w" for write
Returns: Opened Dataset object
Raises:
IOError: If file cannot be openedValueError: If format is not supported
version() -> str
Returns the OxiGDAL version string.
Raster Functions
create_raster(...) -> Dataset
Creates a new raster file.
Parameters:
path: Output file pathwidth: Width in pixelsheight: Height in pixelsbands: Number of bands (default: 1)dtype: Data type (default: "float32")crs: CRS as WKT or EPSG code (optional)nodata: NoData value (optional)
Returns: Created Dataset opened for writing
calc(expression: str, **arrays) -> np.ndarray
Raster calculator - evaluates expressions on raster data.
Parameters:
expression: Mathematical expression (e.g., "(A - B) / (A + B)")**arrays: Named NumPy arrays (A=array1, B=array2, etc.)
Returns: Result array
Supported Operators:
- Arithmetic:
+,-,*,/,**(power) - Comparison:
<,>,<=,>=,==,!= - Functions:
sqrt,abs,log,exp,sin,cos,tan
warp(...) -> None
Reprojects (warps) a raster to different CRS or resolution.
Parameters:
src_path: Source raster pathdst_path: Destination raster pathdst_crs: Target CRS (EPSG code or WKT, optional)width: Target width in pixels (optional)height: Target height in pixels (optional)resampling: Resampling method (default: "bilinear")- Options: "nearest", "bilinear", "cubic", "lanczos"
Vector Functions
read_geojson(path: str) -> dict
Reads a GeoJSON file.
Parameters:
path: Path to GeoJSON file
Returns: Parsed GeoJSON as dictionary
write_geojson(path: str, data: dict, pretty: bool = True) -> None
Writes a GeoJSON file.
Parameters:
path: Output pathdata: GeoJSON data as dictionarypretty: Pretty-print JSON (default: True)
buffer_geometry(geometry: dict, distance: float, segments: int = 8) -> dict
Buffers a geometry by specified distance.
Parameters:
geometry: GeoJSON geometrydistance: Buffer distance in geometry unitssegments: Number of segments per quadrant (default: 8)
Returns: Buffered geometry as GeoJSON
Dataset Class
Properties
path: Dataset file path (read-only)width: Width in pixels (read-only)height: Height in pixels (read-only)band_count: Number of bands (read-only)
Methods
read_band(band: int) -> np.ndarray
Reads a raster band as NumPy array.
Parameters:
band: Band number (1-indexed)
Returns: 2D NumPy array with shape (height, width)
write_band(band: int, array: np.ndarray) -> None
Writes a NumPy array to a raster band.
Parameters:
band: Band number (1-indexed)array: 2D NumPy array to write
get_metadata() -> dict
Returns dataset metadata as a dictionary.
set_metadata(metadata: dict) -> None
Sets dataset metadata.
Parameters:
metadata: Metadata dictionary
close() -> None
Closes the dataset and flushes pending writes.
RasterMetadata Class
Metadata container for raster datasets.
Parameters:
width: Width in pixelsheight: Height in pixelsband_count: Number of bands (default: 1)data_type: Data type as string (default: "float32")crs: CRS as WKT or EPSG code (optional)nodata: NoData value (optional)
Methods:
to_dict(): Converts to dictionary
Exceptions
OxiGdalError
Base exception for all OxiGDAL errors. Inherits from Exception.
Specific error types are mapped to appropriate Python exceptions:
IOError: File I/O errorsValueError: Invalid parameters or dataNotImplementedError: Unsupported operationsRuntimeError: Internal errors
Data Types
Supported raster data types:
uint8,int8uint16,int16uint32,int32uint64,int64float32,float64complex64,complex128
Supported Formats
Raster Formats
- GeoTIFF (
.tif,.tiff) - Cloud Optimized GeoTIFF (COG)
- Zarr (
.zarr) - NetCDF (
.nc)
Vector Formats
- GeoJSON (
.geojson,.json) - FlatGeobuf (
.fgb) - Shapefile (
.shp) - GeoParquet (
.parquet)
Performance Tips
- Use context managers for automatic resource cleanup
- Batch operations when processing multiple files
- Use appropriate data types - smaller types use less memory
- Leverage NumPy for array operations
- Use resampling wisely - "nearest" is fastest, "lanczos" highest quality
Examples
See the examples/ directory for complete examples:
raster_processing.py- Raster I/O and processingndvi_calculation.py- Vegetation index calculationreprojection.py- Coordinate transformationvector_operations.py- GeoJSON and geometry operations
Development
Requirements
- Rust: 1.70 or later
- Python: 3.9 or later
- PyO3: 0.24.x (automatically handled by Cargo)
- Maturin: For building Python wheels
Building from Source
# Install development dependencies
pip install maturin pytest pytest-cov mypy ruff
# Build in debug mode
maturin develop
# Build in release mode
maturin develop --release
# Run tests
pytest tests/
# Type checking
mypy python/oxigdal/
# Linting
ruff check python/
Build Configuration
The crate uses PyO3 with specific feature flags:
- Default features (
extension-module): For building Python extensions (.so/.dylib files) - Without extension-module: For Rust unit tests that need to initialize Python
The extension-module feature prevents linking to libpython (correct for Python extensions), but Rust unit tests need libpython to initialize the interpreter. See "Running Tests" section below for details.
Running Tests
Python Tests (Recommended)
# Run all tests
pytest tests/ -v
# Run with coverage
pytest tests/ --cov=oxigdal --cov-report=html
# Run specific test file
pytest tests/test_raster.py -v
Rust Unit Tests
The library uses PyO3 with the extension-module feature for building Python extensions. To run Rust unit tests, you need to build without this feature:
# Compile library (default - with extension-module)
cargo check -p oxigdal-python --lib
# Compile and run Rust unit tests (without extension-module)
cargo test -p oxigdal-python --no-default-features --features geotiff,geojson,algorithms
# Or using maturin
maturin develop && pytest tests/
Note: The extension-module feature is required for building the Python extension but prevents Rust unit tests from linking to libpython. This is a PyO3 design choice - Python-facing tests should use pytest, while Rust unit tests validate internal logic.
Contributing
Contributions are welcome! Please see CONTRIBUTING.md for guidelines.
License
Licensed under the Apache License, Version 2.0. See LICENSE for details.
Citation
If you use OxiGDAL in your research, please cite:
@software{oxigdal2026,
title = {OxiGDAL: Pure Rust Geospatial Data Abstraction Library},
author = {{COOLJAPAN OU (Team Kitasan)}},
year = {2026},
url = {https://github.com/cool-japan/oxigdal}
}
Acknowledgments
Support
- Documentation: https://docs.rs/oxigdal
- Issue Tracker: https://github.com/cool-japan/oxigdal/issues
- Discussions: https://github.com/cool-japan/oxigdal/discussions
Related Projects
- OxiGDAL Core - Core Rust library
- OxiGDAL WASM - WebAssembly bindings
- OxiGDAL CLI - Command-line interface
Metadata
Release files for oxigdal 0.1.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| oxigdal-0.1.7.tar.gz | 1.8 MB | With provenance | Details for oxigdal-0.1.7.tar.gz |
Built distributions (wheels)
| File | Actions Reset | |||
|---|---|---|---|---|
| oxigdal-0.1.7-cp39-abi3-win_amd64.whl | CPython 3.9 | abi3 | Windows x86-64 | Details for oxigdal-0.1.7-cp39-abi3-win_amd64.whl |
| oxigdal-0.1.7-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl | CPython 3.9 | abi3 | Linux glibc 2.17+ x86-64 | Details for oxigdal-0.1.7-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
| oxigdal-0.1.7-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl | CPython 3.9 | abi3 | Linux glibc 2.17+ ARM64 | Details for oxigdal-0.1.7-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
| oxigdal-0.1.7-cp39-abi3-macosx_11_0_arm64.whl | CPython 3.9 | abi3 | macOS 11.0+ ARM64 | Details for oxigdal-0.1.7-cp39-abi3-macosx_11_0_arm64.whl |
| oxigdal-0.1.7-cp39-abi3-macosx_10_12_x86_64.whl | CPython 3.9 | abi3 | macOS 10.12+ x86-64 | Details for oxigdal-0.1.7-cp39-abi3-macosx_10_12_x86_64.whl |
Total release size: 9.0 MB
Release files / oxigdal-0.1.7.tar.gz
| Download URL | oxigdal-0.1.7.tar.gz |
|---|---|
| Size | 1.8 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0120cf1668983d5466e23c91ac52290bb5d933970b44c22243e3575c74e366a9
|
|
BLAKE2b-256 checksum How to use checksums |
969f0b99cb295a45a96924abf39293ee8ec9945353ba7d815750ef4c9f781d6f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 20, 2026.
Transparency logRelease files / oxigdal-0.1.7-cp39-abi3-win_amd64.whl
| Download URL | oxigdal-0.1.7-cp39-abi3-win_amd64.whl |
|---|---|
| Size | 1.4 MB |
| Tags | CPython 3.9 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
cacb45d728bc2ce1307c692798edfa1b26a55bfe609cfe85b0d4b34b61e78475
|
|
BLAKE2b-256 checksum How to use checksums |
e10b95b16f4df9e29fa0e39c7ed486251d5207ee2e1c1b1d41363a8a1639a6b7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 20, 2026.
Transparency logRelease files / oxigdal-0.1.7-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | oxigdal-0.1.7-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 1.5 MB |
| Tags | CPython 3.9 Linux glibc 2.17+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
940966e39279fcdf3e837a43d42aa051f119d2e52b495a2801fcd07ea72df30a
|
|
BLAKE2b-256 checksum How to use checksums |
1b2fdfa902cf9cf8e09956ea4cd020978985cee1e87e1e0d95fabe5f32abbc28
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 20, 2026.
Transparency logRelease files / oxigdal-0.1.7-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
| Download URL | oxigdal-0.1.7-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 1.5 MB |
| Tags | CPython 3.9 Linux glibc 2.17+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
19a608c9976ccb83400aa8bdefd5efba195e2e04d0175ccd8d508962b9516b84
|
|
BLAKE2b-256 checksum How to use checksums |
3358f8ef23cce1adf519d13bb49082b10d47021d78e2d3d23f1747f8042e127a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 20, 2026.
Transparency logRelease files / oxigdal-0.1.7-cp39-abi3-macosx_11_0_arm64.whl
| Download URL | oxigdal-0.1.7-cp39-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 1.4 MB |
| Tags | CPython 3.9 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
bf9913fefdf85927653b163d5c26521b19594b0ff24922679732cfbedd3417d9
|
|
BLAKE2b-256 checksum How to use checksums |
0e8d8777ca0cfc3d1eca7c6c2dc88887600510d6c27b557c0fd2c4a2a50ef169
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 20, 2026.
Transparency logRelease files / oxigdal-0.1.7-cp39-abi3-macosx_10_12_x86_64.whl
| Download URL | oxigdal-0.1.7-cp39-abi3-macosx_10_12_x86_64.whl |
|---|---|
| Size | 1.5 MB |
| Tags | CPython 3.9 abi3 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
425a4354886ff4add95b7bc8ce24d11fcb8be140f2ddcf4804bf134fce4f8500
|
|
BLAKE2b-256 checksum How to use checksums |
c8c3cc37d080e45c34eb3d5d9bc58b662cda50b8bdb6d5e2e4c3514adc03bbac
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 20, 2026.
Transparency logSecurity for oxigdal 0.1.7
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 6 files in this release have been uploaded with provenance metadata.
Attestation for oxigdal-0.1.7.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 20, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.