Skip to main content

Map Algebra with NumPy

Inspired by the ARC/INFO GRID implementation of Map Algebra.

Installation

# PyPI
pip install glidergun
# UV
uv add glidergun

For CUDA acceleration, install the PyTorch CUDA wheels before installing glidergun.

Installation

# PyPI
pip install glidergun
# UV
uv add glidergun

For CUDA acceleration, install the PyTorch CUDA wheels before installing glidergun.

# PyPI
pip install torch torchvision --index-url https://download.pytorch.org/whl/cu130
# PyPI
pip install torch torchvision --index-url https://download.pytorch.org/whl/cu130
pip install glidergun
# UV
uv add torch torchvision --index pytorch-cu130=https://download.pytorch.org/whl/cu130
uv add glidergun

Getting Started

Terrain analysis

# Downloads a Copernicus DEM and creates a hillshade GeoTIFF.
# Downloads a Copernicus DEM and creates a hillshade GeoTIFF.
from glidergun import grid

dem = grid("cop-dem-glo-90", (137.8, 34.5, 141.1, 36.8))
hillshade = dem.hillshade()

dem.save("dem.tif")
hillshade.save("hillshade.tif", "uint8")

Image segmentation

# Downloads a Bing aerial image, runs SAM segmentation,
# and saves the detected objects as GeoJSON.
# Downloads a Bing aerial image, runs SAM segmentation,
# and saves the detected objects as GeoJSON.
from glidergun import stack

bing = stack("microsoft", (-123.164, 49.272, -123.162, 49.273), max_tiles=100)
bing.save("vancouver.tif")

sam = bing.sam("tree", "house", "car")
sam.to_geojson().save("vancouver.json")

Both examples access online services. Running SAM may require Hugging Face authorization or a model checkpoint, depending on your model setup.

Library Overview

Glidergun is a Python library for geospatial raster analysis and map algebra. It brings NumPy-style expressions to georeferenced raster data, keeping coordinate reference system (CRS), extent, and cell size attached to each grid. It is designed for interactive exploration in notebooks as well as repeatable analysis scripts.

Grids and stacks

The main objects are Grid and Stack. A Grid represents one raster band; a Stack groups aligned bands, such as the red, green, and blue channels of an image. Create them with grid(...) and stack(...) from NumPy arrays, raster files, Rasterio datasets, or supported remote sources.

Map algebra and raster analysis

Use arithmetic and comparison operators directly on grids and stacks; bitwise operators are available for compatible data types. Operations can combine raster data with scalars or other grids. When grids share a CRS but differ in extent or cell size, Glidergun can align them for the operation. Conditional expressions, reclassification, range clipping, scaling, and band aggregation are also available.

For spatial analysis, Glidergun includes focal neighborhood statistics and filters, zonal statistics, interpolation, terrain derivatives such as slope and aspect, hillshade, and rasterization. Convert raster cells to point or polygon features, or burn geometries and points into a grid. Grids can also be clipped, resampled, reprojected, mosaicked, and processed in tiles.

Data access and output

Read and write raster formats supported by Rasterio/GDAL. Search STAC catalogs such as Microsoft Planetary Computer for imagery and elevation data, or load supported web tile services and basemaps. Save results as raster files or serialize them to bytes; export vector features as GeoJSON.

Imagery and interactive workflows

Stacks support per-band operations and conversion to NumPy arrays. Computer-vision workflows include image georeferencing with LoFTR and text-prompted segmentation with SAM. In notebooks, preview and animate grids and stacks; in supported ArcGIS Pro and QGIS sessions, add results to the active map.

Metadata

Release files for glidergun 0.9.191

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for glidergun 0.9.191
File Size Uploaded Provenance Actions
glidergun-0.9.191.tar.gz 47.2 kB Without provenance Details for glidergun-0.9.191.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for glidergun 0.9.191
File Interpreter ABI Platform Actions
glidergun-0.9.191-py3-none-any.whl Python 3 none any Details for glidergun-0.9.191-py3-none-any.whl

Total release size: 98.1 kB

Release files / glidergun-0.9.191.tar.gz

Download URL glidergun-0.9.191.tar.gz
Size 47.2 kB
Tags Source
SHA-256 checksum
How to use checksums
5d09b8d668fa600b27e8a763a7bb75d92c193349730a78c032e6dac5b3452b89
BLAKE2b-256 checksum
How to use checksums
5dbc0bf22d57e3d45bfb489906c392eaf7a7660f1644f4f158489a24d201ce37
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.8 {"installer":{"name":"uv","version":"0.13.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / glidergun-0.9.191-py3-none-any.whl

Download URL glidergun-0.9.191-py3-none-any.whl
Size 50.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7c7684b3d147a67e1dac04cfdb8c8ab0a4372f64c52f1b6b0fcafd550582a4fe
BLAKE2b-256 checksum
How to use checksums
b96bf034fe7b46f931c92b9a201adfc4d55df5f66c3e32224d2ce86d0e2a9f42
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.8 {"installer":{"name":"uv","version":"0.13.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for glidergun 0.9.191

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A 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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page