r/gis • • 2d ago

Projects & Feedback I built GeoStride: a pure-Python, zero-GDAL spatial analysis & trajectory library

[AI Disclosure] AI was used for assisting with test suite generation, code refactoring, and drafting documentation.

[GIS Experience] Python geospatial developer and open-source contributor focusing on spatial feature engineering, discrete indexing, and trajectory kinematics.

Hey everyone,

I wanted to share GeoStride, an open-source lightweight Python library for spatial feature engineering, trajectory kinematics, and spatial statistics.

GitHub: https://github.com/Rohan-Dedhia/geostride PyPI: https://pypi.org/project/geostride/

Install: pip install geostride

Why I built it: The standard GIS ecosystem (GeoPandas, Shapely, PySAL) is the gold standard for heavy GIS work. But when deploying to serverless environments (AWS Lambda), lightweight Docker containers, or edge devices, compiling C/C++ GIS bindings like GDAL, GEOS, and PROJ often causes build headaches.

GeoStride is pure Python built strictly on NumPy, Pandas, and SciPy (< 2 MB footprint) with zero C-dependency requirements.

Key features in v0.2.0: • Trajectory Kinematics: Speed, acceleration, heading, sinuosity, and spherical Slerp resampling. • Trajectory Simplification: Geodesic Douglas-Peucker operating directly on great circles. • Spatial Statistics: Global Moran's I, LISA local clusters (High-High, Low-Low), Getis-Ord Gi*, and spatial weights matrix standardization. • Zero-Dependency Maps & I/O: WKT and GeoJSON parsers, plus standalone interactive Leaflet & Choropleth HTML map exports. • Scikit-Learn Integration: Native SpatialLagTransformer and SpatialKFold cross-validator.

We have 212 unit tests running across Python 3.10–3.13 on Linux, macOS, and Windows.

Would love to get your feedback and thoughts from the GIS community!

1 Upvotes

5 comments sorted by

1

u/mfc1__ GIS Developer 2d ago

How do the benchmarks compare?

2

u/Tech_newz 1d ago

Good question! Here is how the current benchmarks look from the built-in suite (python -m benchmarks.run_benchmarks):

  • Pairwise Haversine Distance (N = 50,000 pairs): ~4.4 ms (~11.3M ops/s), which is ~13x–24x faster than standard Python loops thanks to vectorized NumPy broadcasting.
  • Haversine Distance Matrix (500 x 500 = 250,000 pairs): ~29 ms (~8.4M ops/s).
  • Morton Z-Order Encoding (N = 30,000 coords): ~113 ms (~265,000 ops/s).
  • SpatialKFold Partitioning (N = 20,000 points): ~63 ms (~315,000 points/s).
  • Spatial Autocorrelation (Global Moran's I, LISA, Getis-Ord): Runs in milliseconds on tabular spatial data using vectorized permutations without needing the full PySAL dependency stack.

How it compares to the broader stack:

  • vs. Naive Python loops: 13x–25x speedup across geodetic distance calculations and spatial indexing.
  • vs. Shapely / GEOS (C++): For massive, complex multi-polygon topological overlays, GEOS's native C++ engine will still be faster. GeoStride isn't trying to replace GDAL/GEOS for heavy desktop GIS.
  • The design sweet spot: GeoStride is built directly on pure NumPy/Pandas/SciPy. It gives you 90% of the daily spatial feature engineering tools (distances, spatial lags, spatial autocorrelation, trajectory kinematics, discrete binning) with zero C/C++ compilation, no GDAL conflicts, and an install footprint of under 2 MB—making it ideal for AWS Lambda, Docker microservices, and scikit-learn ML pipelines where GDAL is a headache to deploy.

If you have a specific operation or library you’d like to see benchmarked against (e.g. against esda or fastdtw), let me know and I’d be happy to add it to the benchmark suite!

1

u/mfc1__ GIS Developer 1d ago

Noice, I was curious if anything significant is lost going the pure python route

1

u/Tech_newz 1d ago

Totally fair question! There are definitely real trade-offs. Here is what you genuinely give up compared to the full GDAL/GEOS stack:

  1. Arbitrary Coordinate Reference System (CRS) Reprojections: Without PROJ/pyproj, you cannot dynamically reproject between hundreds of niche local datums or state plane coordinate systems on the fly. GeoStride is designed around standard WGS84 (lat/lon) with spherical and ellipsoidal geodesy (Haversine/Vincenty) and local metric planar projections.
  2. Heavyweight Polygon Topology and Boolean Overlays: GEOS is a decades-old, industrial-strength C++ engine. If you need to perform cascaded unions, difference overlays, or clipping on massive multi-polygons with 100,000+ vertices, GEOS/Shapely will beat pure Python. GeoStride handles point-in-polygon ray-casting, geodesic buffering, concave/convex hulls, and R-tree spatial joins, but does not try to be a full constructive geometry engine.
  3. Rasters and Legacy GIS File Formats: GDAL is the swiss-army knife for 200+ formats (GeoTIFFs, COGs, Esri FileGDB, Shapefiles, NetCDF). GeoStride focuses strictly on vector and tabular points and trajectories, sticking to clean RFC 7946 GeoJSON, WKT, and Pandas/NumPy streams.

What you DO NOT lose: Raw throughput for tabular spatial data. Because GeoStride builds on top of NumPy and SciPy (which are already compiled C and BLAS under the hood), vectorized geodetics, spatial autocorrelation (Moran's I, Getis-Ord), spatial indexing (Geohash, Morton curves), and trajectory kinematics execute in milliseconds.

The sweet spot: If you are doing heavy desktop cartography or satellite imagery analysis, stick with GeoPandas and GDAL. But if you are building serverless microservices (AWS Lambda, Cloud Functions), edge IoT pipelines, or Scikit-Learn ML workflows where you just need spatial features, clustering, and trajectory analysis without a 500MB Docker image and GDAL compilation errors, GeoStride gives you that in a lightweight install under 2MB.