Metadata-Version: 2.4
Name: glidergun
Version: 0.9.191
Summary: Map Algebra with NumPy
License-Expression: MIT
Project-URL: Homepage, https://github.com/jshirota/glidergun
Project-URL: Bug Tracker, https://github.com/jshirota/glidergun/issues
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: contourpy>=1.3.3; python_version >= "3.14"
Requires-Dist: ipython>=7.31.1; python_version == "3.10"
Requires-Dist: ipython>=8.0.0; python_version == "3.11"
Requires-Dist: ipython>=8.16.0; python_version == "3.12"
Requires-Dist: ipython>=8.28.0; python_version == "3.13"
Requires-Dist: ipython>=8.31.1; python_version >= "3.14"
Requires-Dist: kornia>=0.6.2; python_version == "3.10"
Requires-Dist: kornia>=0.6.7; python_version == "3.11"
Requires-Dist: kornia>=0.7.1; python_version == "3.12"
Requires-Dist: kornia>=0.7.4; python_version == "3.13"
Requires-Dist: kornia>=0.8.2; python_version >= "3.14"
Requires-Dist: matplotlib>=3.5.0; python_version == "3.10"
Requires-Dist: matplotlib>=3.6.2; python_version == "3.11"
Requires-Dist: matplotlib>=3.8.0; python_version == "3.12"
Requires-Dist: matplotlib>=3.9.4; python_version == "3.13"
Requires-Dist: matplotlib>=3.10.8; python_version >= "3.14"
Requires-Dist: numpy>=1.21.2; python_version == "3.10"
Requires-Dist: numpy>=1.23.2; python_version == "3.11"
Requires-Dist: numpy>=1.26.0; python_version == "3.12"
Requires-Dist: numpy>=2.1.0; python_version == "3.13"
Requires-Dist: numpy>=2.4.4; python_version >= "3.14"
Requires-Dist: opencv-python>=4.5.4; python_version == "3.10"
Requires-Dist: opencv-python>=4.6.0; python_version == "3.11"
Requires-Dist: opencv-python>=4.8.1; python_version == "3.12"
Requires-Dist: opencv-python>=4.10.0; python_version == "3.13"
Requires-Dist: opencv-python>=4.13.0; python_version >= "3.14"
Requires-Dist: planetary-computer>=1.0.0
Requires-Dist: rasterio>=1.3.3; python_version == "3.10"
Requires-Dist: rasterio>=1.3.3; python_version == "3.11"
Requires-Dist: rasterio>=1.3.9; python_version == "3.12"
Requires-Dist: rasterio>=1.4.0; python_version == "3.13"
Requires-Dist: rasterio>=1.4.4; python_version >= "3.14"
Requires-Dist: sam-prompt>=0.1.4
Requires-Dist: scikit-learn>=1.0.0; python_version == "3.10"
Requires-Dist: scikit-learn>=1.1.0; python_version == "3.11"
Requires-Dist: scikit-learn>=1.3.0; python_version == "3.12"
Requires-Dist: scikit-learn>=1.5.0; python_version == "3.13"
Requires-Dist: scikit-learn>=1.8.0; python_version >= "3.14"
Requires-Dist: scipy>=1.7.1; python_version == "3.10"
Requires-Dist: scipy>=1.9.0; python_version == "3.11"
Requires-Dist: scipy>=1.11.0; python_version == "3.12"
Requires-Dist: scipy>=1.14.1; python_version == "3.13"
Requires-Dist: scipy>=1.17.1; python_version >= "3.14"
Requires-Dist: shapely>=1.8.0; python_version == "3.10"
Requires-Dist: shapely>=1.8.5; python_version == "3.11"
Requires-Dist: shapely>=2.0.2; python_version == "3.12"
Requires-Dist: shapely>=2.0.6; python_version == "3.13"
Requires-Dist: shapely>=2.1.2; python_version >= "3.14"
Requires-Dist: torch>=2.0.0; python_version == "3.10" or python_version == "3.11"
Requires-Dist: torch>=2.5.0; python_version == "3.12"
Requires-Dist: torch>=2.6.0; python_version == "3.13"
Requires-Dist: torch>=2.11.0; python_version >= "3.14"
Requires-Dist: torchvision>=0.15.0; python_version == "3.10" or python_version == "3.11"
Requires-Dist: torchvision>=0.20.0; python_version == "3.12"
Requires-Dist: torchvision>=0.21.0; python_version == "3.13"
Requires-Dist: torchvision>=0.26.0; python_version >= "3.14"
Dynamic: license-file

# Map Algebra with NumPy

Inspired by the ARC/INFO GRID implementation of [Map Algebra](https://en.m.wikipedia.org/wiki/Map_algebra).

## Installation

```bash
# PyPI
pip install glidergun
```

```bash
# UV
uv add glidergun
```

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

```bash
# PyPI
pip install glidergun
```

```bash
# UV
uv add glidergun
```

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

```bash
# 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
```

```bash
# UV
uv add torch torchvision --index pytorch-cu130=https://download.pytorch.org/whl/cu130
uv add glidergun
```

## Getting Started

### Terrain analysis

```python
# 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

```python
# 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.
