OxiGeo Node.js Bindings
Production-ready Node.js bindings for OxiGeo - Pure Rust geospatial data processing
Features
- Pure Rust Performance: No C/C++ dependencies, full native performance
- Zero-Copy Buffers: Efficient data transfer between Node.js and Rust
- Async/Await Support: Promise-based async operations for I/O and processing
- TypeScript Definitions: Full TypeScript support with comprehensive type definitions
- Comprehensive APIs: Raster I/O, vector operations, terrain analysis, and more
- Cloud-Native: COG (Cloud Optimized GeoTIFF) support built-in
- Cross-Platform: Works on Linux, macOS, and Windows (x64, ARM64)
Installation
Or with yarn:
Quick Start
Raster Operations
const oxigeo = require;
// Open a raster file
const dataset = oxigeo.;
console.log;
console.log;
// Read a band
const band = dataset.;
const stats = band.;
console.log;
// Create output
const output = oxigeo.;
output.;
output.;
Terrain Analysis
const oxigeo = require;
.;
Vector Operations
const oxigeo = require;
// Read GeoJSON
const collection = oxigeo.;
console.log;
// Create new feature
const point = oxigeo.;
const feature = ;
feature.;
collection.;
// Buffer operation
const buffered = oxigeo.;
// Area calculation
const polygon = oxigeo.;
const area = oxigeo.;
console.log;
// Save
oxigeo.;
API Documentation
Raster API
Dataset
// Create or open
const dataset = oxigeo.;
const dataset = oxigeo.;
// Properties
dataset.
dataset.
dataset.
dataset.
dataset.
dataset.
// Geo transform
dataset.;
const gt = dataset.;
// Coordinate conversion
const geo = dataset.;
const pixel = dataset.;
// Band I/O
const band = dataset.;
dataset.;
const window = dataset.;
// Save
dataset.;
BufferWrapper
// Create
const buffer = ;
// Pixel access
buffer.;
const value = buffer.;
// Operations
buffer.;
const stats = buffer.; // { min, max, mean, stddev, count }
const cloned = buffer.;
// Node.js Buffer conversion
const nodeBuffer = buffer.;
const buffer = oxigeo.;
Vector API
Geometry
// Create geometries
const point = oxigeo.;
const linestring = oxigeo.;
const polygon = oxigeo.;
// Properties
geometry.
geometry. // [minX, minY, maxX, maxY]
// GeoJSON
const geojson = geometry.;
const geometry = oxigeo.;
Feature & FeatureCollection
// Features
const feature = ;
feature.;
const value = feature.;
const geojson = feature.;
// Collections
const collection = ;
collection.;
const feature = collection.;
const count = collection.;
// I/O
const collection = oxigeo.;
oxigeo.;
Algorithm API
Resampling
const resampled = oxigeo.;
// Methods: NearestNeighbor, Bilinear, Bicubic, Lanczos
Terrain Analysis
// pixelSize is the DEM's ground resolution (e.g. meters or degrees),
// matching its coordinate reference system.
// Hillshade
const hillshade = oxigeo.;
// Slope (degrees or percent, depending on asPercent)
const slope = oxigeo.;
// Aspect
const aspect = oxigeo.;
// Zonal statistics
const stats = oxigeo.;
// Returns: [{ zoneId, count, min, max, mean, stddev, sum }, ...]
Raster Calculator
Evaluates a map-algebra expression across one or more input bands. Bands are
referenced positionally as B1, B2, ... (1-indexed). The language supports
arithmetic (+ - * / ^), math functions (sqrt, log, log10, exp,
abs, floor, ceil, round, sin, cos, tan, min, max),
comparisons (> < >= <= == !=), logical and/or, and if/then/else.
// NDVI = (NIR - RED) / (NIR + RED)
const ndvi = oxigeo.;
// Math functions and conditionals
const magnitude = oxigeo.;
const mask = oxigeo.;
Vector Algorithms
// Buffer
const buffered = oxigeo.;
// Area
const area = oxigeo.;
// Simplify
const simplified = oxigeo.;
Async API
All major operations have async variants:
// Raster I/O
const dataset = await oxigeo.;
await oxigeo.;
// Vector I/O
const collection = await oxigeo.;
await oxigeo.;
// Processing
const resampled = await oxigeo.;
const hillshade = await oxigeo.;
const slope = await oxigeo.;
const aspect = await oxigeo.;
const stats = await oxigeo.;
// Batch processing.
// `operation` is a per-pixel transform applied to every band:
// 'identity' | 'abs' | 'negate' | 'square' | 'sqrt'
const paths = await oxigeo.;
// `processRasterParallel` splits each band into `chunkSize`-row chunks and
// applies the operation across `numThreads` worker threads.
const config = ;
const result = await oxigeo.;
// Progress reporting: register a callback before starting a long-running
// operation to receive periodic progress fractions in [0.0, 1.0].
oxigeo.;
await oxigeo.;
oxigeo.;
Stream Processing
For large datasets:
const stream = ;
let chunk;
while
Cancellation
A CancellationToken can be passed to the long-running batch/parallel
processors. When it is cancelled while work is in flight, the operation aborts
with a CANCELLED error instead of returning partially-processed data (chunks
not yet started are skipped; already-written batch outputs are left in place).
const token = ;
// Pass the token into a long-running operation.
const promise = oxigeo.;
// Cancel it from elsewhere (e.g. a timeout or a user action).
setTimeout;
try catch
// The token can be reused after resetting it.
token.;
The token is likewise accepted as the trailing argument of
batchProcessRasters(paths, outputDir, operation, token).
Data Types
Supported raster data types:
'uint8'- Unsigned 8-bit integer'int16'- Signed 16-bit integer'uint16'- Unsigned 16-bit integer'int32'- Signed 32-bit integer'uint32'- Unsigned 32-bit integer'float32'- 32-bit floating point'float64'- 64-bit floating point
Supported Formats
Raster
- GeoTIFF (.tif, .tiff) - Full support including COG
Vector
- GeoJSON (.json, .geojson) - Full support
Examples
See the examples/ directory for complete examples:
01_basic_raster.js- Basic raster I/O and operations02_terrain_analysis.js- DEM processing and terrain analysis03_vector_operations.js- Vector I/O and geometry operations04_async_batch.js- Async operations and batch processing
Run examples:
Testing
Run with coverage:
Performance
OxiGeo Node.js bindings are designed for production use with:
- Zero-copy data transfer where possible
- SIMD vectorization (x86_64 AVX2, ARM NEON)
- Multi-threaded operations via Rust's async runtime
- Optimized memory usage with custom allocators
TypeScript
Full TypeScript support is included:
import * as oxigeo from '@cooljapan/oxigeo-node';
const dataset: oxigeo.Dataset = oxigeo.openRaster('input.tif');
const band: oxigeo.BufferWrapper = dataset.readBand(0);
const stats: oxigeo.Statistics = band.statistics();
async function process(): Promise<void> {
const hillshade = await oxigeo.hillshadeAsync(band, 315, 45, 1.0, 30.0);
// ...
}
Error Handling
All operations use standard JavaScript errors:
try catch
Platform Support
- Linux: x86_64, aarch64 (glibc and musl)
- macOS: x86_64, Apple Silicon (M1/M2)
- Windows: x86_64, aarch64 (ARM64)
Building from Source
Requirements:
- Rust 1.89+
- Node.js 16+
License
Apache-2.0
Contributing
Contributions are welcome! Please see CONTRIBUTING.md for guidelines.
Links
Authors
COOLJAPAN OU (Team Kitasan)
OxiGeo - Pure Rust geospatial processing for the modern age.