Custom spatial analysis package with GeoPandas-style frame workflows and GeoPrompt equations.
Project description
Geoprompt
Custom spatial analysis package for point, line, and polygon workflows, GeoPandas-style frame access, GeoJSON-compatible inputs and outputs, CRS-aware reprojection, spatial joins, geographic distance options, and GeoPrompt-specific equations for influence, interaction, corridor strength, and neighborhood pressure.
Snapshot
- Lane: Spatial package design
- Domain: Reusable custom spatial analysis
- Stack: Python, JSON fixtures, lightweight geometry frame, custom equations
- Includes: GeoPromptFrame object, mixed-geometry helpers, GeoJSON I/O, CRS metadata and reprojection, Euclidean and haversine distance tools, bounding-box queries, radius queries, within-distance predicates, spatial joins, proximity joins, nearest joins, nearest assignment workflows, assignment summaries, buffer, buffer joins, coverage summaries, dissolve, clip and overlay intersections, nearest-neighbor analysis, comparison report tooling, custom influence equations, benchmark corpus, demo report, tests
Overview
This project starts a reusable spatial package lane instead of another one-off analysis repo. The goal is to build a custom package that users can import directly, similar to how they would reach for GeoPandas, but focused first on a small and clear set of spatial equations that can grow over time.
The initial version still stays intentionally simple, but it now goes beyond points: the frame can work with points, lines, and polygons represented through a small GeoJSON-like geometry mapping. That keeps the package small enough to iterate on while still showing a real package design direction.
What It Demonstrates
- A package-first project structure rather than a single lab script
- A
GeoPromptFrameobject that behaves like a lightweight spatial table wrapper - GeoJSON FeatureCollection support so callers can use standard spatial data without reshaping it first
- Custom equations for spatial decay, influence, interaction, corridor strength, and area similarity scoring
- Basic nearest-neighbor analysis for point, line, and polygon centroids
- Bounding-box queries for quick map-window style filtering
- Radius queries for fast proximity filtering around a feature or coordinate anchor
- Within-distance predicates for scoring or filtering without materializing a join
- CRS assignment and reprojection through
GeoPromptFrame.to_crs(...) - Spatial joins with
intersects,within, andcontainspredicates - Proximity joins for distance-based matching without needing an overlay engine
- Nearest joins for
kclosest matches when you want ranked association instead of a fixed distance cutoff - Nearest assignment for allocating each target feature to a single closest origin
- Assignment summaries for rolling nearest assignments into per-origin counts, ids, and aggregate metrics
- Buffer generation for point, line, and polygon geometries through the overlay engine
- Buffer joins for service-area style matching against surrounding features
- Coverage summaries for fast count and aggregate rollups per service geometry
- Dissolve workflows with
GeoPromptFrame.dissolve(...) - Overlay operations with
GeoPromptFrame.clip(...)andGeoPromptFrame.overlay_intersections(...) - Geographic distance support for longitude/latitude point workflows through haversine distance
- Pairwise interaction analysis without requiring pandas or geopandas
- A demo CLI that exports a real review plot and JSON report from checked-in mixed geometry features
- A comparison CLI that checks Geoprompt outputs against Shapely and GeoPandas across a built-in corpus and records timing data
Example Usage
import geoprompt as gp
frame = gp.read_points("data/sample_points.json")
scored = frame.assign(
neighborhood_pressure=lambda current: current.neighborhood_pressure(
weight_column="demand_index",
scale=0.14,
power=1.6,
)
)
print(scored.head(2))
print(scored.centroid())
print(scored.nearest_neighbors())
Mixed geometry example:
import geoprompt as gp
features = gp.read_features("data/sample_features.json")
print(features.geometry_types())
print(features.geometry_lengths())
print(features.geometry_areas())
print(features.query_bounds(-111.97, 40.68, -111.84, 40.79).head())
projected = features.set_crs("EPSG:4326").to_crs("EPSG:3857")
print(projected.bounds())
print(features.nearest_neighbors(k=2)[:4])
Spatial join example:
import geoprompt as gp
regions = gp.read_features("data/benchmark_regions.json", crs="EPSG:4326")
assets = gp.read_features("data/benchmark_features.json", crs="EPSG:4326")
joined = regions.spatial_join(assets, predicate="contains")
print(joined.head(3))
Proximity query and join example:
import geoprompt as gp
assets = gp.read_features("data/benchmark_features.json", crs="EPSG:4326")
regions = gp.read_features("data/benchmark_regions.json", crs="EPSG:4326")
nearby = assets.query_radius(anchor="alpha-point", max_distance=0.06)
proximity = regions.proximity_join(assets, max_distance=0.08)
print(nearby.head(3))
print(proximity.head(3))
Nearest-join example:
import geoprompt as gp
origins = gp.read_features("data/sample_features.json", crs="EPSG:4326")
targets = gp.read_features("data/benchmark_features.json", crs="EPSG:4326")
nearest = origins.nearest_join(targets, k=2, max_distance=0.08, how="left")
print(nearest.head(4))
Nearest-assignment example:
import geoprompt as gp
origins = gp.read_features("data/sample_features.json", crs="EPSG:4326")
targets = gp.read_features("data/benchmark_features.json", crs="EPSG:4326")
assigned = origins.assign_nearest(targets, max_distance=0.08, how="left")
print(assigned.head(4))
Assignment-summary example:
import geoprompt as gp
origins = gp.read_features("data/sample_features.json", crs="EPSG:4326")
targets = gp.read_features("data/benchmark_features.json", crs="EPSG:4326")
summary = origins.summarize_assignments(
targets,
aggregations={"demand_index": "sum"},
max_distance=0.08,
)
print(summary.head(4))
Buffer and within-distance example:
import geoprompt as gp
assets = gp.read_features("data/sample_features.json", crs="EPSG:4326")
mask = assets.within_distance(anchor="north-hub-point", max_distance=0.08)
buffers = assets.buffer(distance=0.01)
print(mask)
print(buffers.head(2))
Service-area example:
import geoprompt as gp
origins = gp.read_features("data/sample_features.json", crs="EPSG:4326")
targets = gp.read_features("data/benchmark_features.json", crs="EPSG:4326")
service_matches = origins.buffer_join(targets, distance=0.03)
coverage = origins.buffer(distance=0.03).coverage_summary(
targets,
aggregations={"demand_index": "sum"},
)
print(service_matches.head(3))
print(coverage.head(3))
Overlay example:
import geoprompt as gp
regions = gp.read_features("data/benchmark_regions.json", crs="EPSG:4326")
assets = gp.read_features("data/benchmark_features.json", crs="EPSG:4326")
clipped = assets.clip(regions)
intersections = regions.overlay_intersections(assets)
print(clipped.head(3))
print(intersections.head(3))
Dissolve example:
import geoprompt as gp
regions = gp.read_features("data/benchmark_regions.json", crs="EPSG:4326")
dissolved = regions.dissolve(by="region_band", aggregations={"region_name": "count"})
print(dissolved.head())
GeoJSON example:
import geoprompt as gp
frame = gp.read_geojson("service-zones.geojson")
nearest = frame.nearest_neighbors(k=1)
nearest_km = frame.nearest_neighbors(k=1, distance_method="haversine")
gp.write_geojson("service-zones-scored.geojson", frame)
print(nearest)
print(nearest_km)
Project Structure
geoprompt/
|-- data/
| |-- benchmark_features.json
| |-- benchmark_regions.json
| |-- sample_features.json
| `-- sample_points.json
|-- assets/
| `-- neighborhood-pressure-review-live.png
|-- .github/
| `-- workflows/
| `-- geoprompt-ci.yml
|-- src/geoprompt/
| |-- __init__.py
| |-- compare.py
| |-- demo.py
| |-- geometry.py
| |-- overlay.py
| |-- equations.py
| |-- frame.py
| `-- io.py
|-- tests/
| `-- test_geoprompt.py
|-- docs/
| |-- architecture.md
| `-- demo-storyboard.md
|-- outputs/
| |-- charts/
| | `-- .gitkeep
| `-- .gitkeep
|-- pyproject.toml
`-- README.md
Quick Start
pip install -e .[dev]
geoprompt-demo
Install the optional comparison stack when you want to validate against Shapely and GeoPandas:
pip install -e .[compare]
geoprompt-compare
Install only projection support if you want CRS transforms without the full comparison stack:
pip install -e .[projection]
Install only overlay support if you want clip and intersection operations without the full comparison stack:
pip install -e .[overlay]
Install the published package from PyPI with:
pip install geoprompt
Run tests:
pytest
Current Output
The default demo command writes outputs/geoprompt_demo_report.json and outputs/charts/neighborhood-pressure-review.png with:
- a frame-level centroid and bounds summary
- CRS and projected Web Mercator bounds metadata
- mixed geometry type summaries, line lengths, and polygon areas
- nearest-neighbor rows for each feature in planar and geographic modes
- per-site neighborhood pressure scores
- anchor influence scores from a selected source node
- corridor accessibility scores for line-style features
- top pairwise interaction rows ranked by the GeoPrompt interaction equation
- top area-similarity rows ranked across polygon-like features
- a bounding-box query count for the default valley review window
- a GeoJSON export in
outputs/geoprompt_demo_features.geojson - a committed pressure plot in
assets/neighborhood-pressure-review-live.png
CI validation is defined in .github/workflows/geoprompt-ci.yml and runs tests, demo generation, comparison validation, and package builds.
It also runs python -m twine check dist/* so distribution metadata is validated before release.
See docs/architecture.md for the package design notes. See docs/demo-storyboard.md for the reviewer walkthrough.
Custom Equations
- Prompt decay:
1 / (1 + distance / scale) ^ power - Prompt influence:
weight * prompt_decay(distance, scale, power) - Prompt interaction:
origin_weight * destination_weight * prompt_decay(distance, scale, power) - Corridor strength:
weight * log(1 + corridor_length) * prompt_decay(distance, scale, power) - Area similarity:
min(area_a, area_b) / max(area_a, area_b) * prompt_decay(distance, scale, power)
These are intentionally simple first equations. The package now supports two distance modes:
euclideanfor planar coordinate space and direct comparison with Shapely and GeoPandas raw-coordinate resultshaversinefor geographic point-to-point distances in kilometers when your coordinates are longitude/latitude
The package now supports CRS tagging and reprojection, but it is still designed so richer CRS handling, overlays, and additional operators can be layered in later.
Package Interface
The main package entry points are:
geoprompt.read_points(...)geoprompt.read_features(...)geoprompt.read_geojson(...)geoprompt.write_geojson(...)geoprompt.haversine_distance(...)GeoPromptFrame.set_crs(...)GeoPromptFrame.to_crs(...)GeoPromptFrame.nearest_neighbors(...)GeoPromptFrame.query_bounds(...)GeoPromptFrame.query_radius(...)GeoPromptFrame.within_distance(...)GeoPromptFrame.spatial_join(...)GeoPromptFrame.proximity_join(...)GeoPromptFrame.nearest_join(...)GeoPromptFrame.assign_nearest(...)GeoPromptFrame.summarize_assignments(...)GeoPromptFrame.buffer(...)GeoPromptFrame.buffer_join(...)GeoPromptFrame.coverage_summary(...)GeoPromptFrame.dissolve(...)GeoPromptFrame.clip(...)GeoPromptFrame.overlay_intersections(...)GeoPromptFrame.neighborhood_pressure(...)GeoPromptFrame.anchor_influence(...)GeoPromptFrame.corridor_accessibility(...)GeoPromptFrame.interaction_table(...)GeoPromptFrame.area_similarity_table(...)
Comparison Workflow
Before calling Geoprompt production-ready, use the comparison CLI to verify results and get a timing snapshot against Shapely and GeoPandas:
geoprompt-compare
This writes outputs/geoprompt_comparison_report.json with:
- core metric agreement across the built-in sample and benchmark corpora
- core metric agreement across a generated stress corpus with 93 features and 16 join regions
- reprojection agreement against GeoPandas in EPSG:3857
- dissolve agreement against GeoPandas on the benchmark region corpus
- spatial-join agreement against Shapely and GeoPandas-style predicate behavior
- nearest-neighbor agreement against a Shapely centroid-distance reference
- bounding-box query agreement against GeoPandas
- timing summaries for geometry metrics, reprojection, bounds queries, nearest neighbors, dissolve, clip, and joins
Current validated snapshot from the built-in corpora:
- correctness parity flags are all
truefor bounds, nearest neighbors, bounds queries, geometry metrics, reprojection, clip, dissolve, and spatial join - Geoprompt is consistently faster on geometry metrics, nearest-neighbor lookup, bounds queries, and dissolve
- the generated stress corpus now shows Geoprompt ahead on both spatial join and clip
- the smaller benchmark corpus still shows
clipandspatial_jointrailing the reference path, which is the clearest target for the next optimization pass
Representative relative speed ratios from the latest comparison report:
samplecorpus: geometry metrics5.09x, nearest neighbors2.16x, bounds query23.86x, reprojection1.58xbenchmarkcorpus: geometry metrics10.35x, nearest neighbors4.44x, bounds query9.32x, reprojection1.18x, clip0.78x, spatial join0.37x, dissolve19.68xstresscorpus: geometry metrics6.98x, nearest neighbors9.25x, bounds query3.41x, reprojection1.17x, clip1.20x, spatial join3.18x, dissolve7.96x
Release Readiness
The project now includes:
- an MIT license in
LICENSE - a GitHub Actions workflow for repeatable validation
- a checked-in benchmark corpus for broader parity testing
- packaging extras for comparison, projection, and overlay support
Publication
- License: LICENSE
- Standalone publishing notes: PUBLISHING.md
- Changelog: CHANGELOG.md
- Release notes: docs/release-notes-0.1.6.md
- Tool roadmap: docs/tool-roadmap.md
Repository Notes
This copy is intended to be publishable as its own repository.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file geoprompt-0.1.6.tar.gz.
File metadata
- Download URL: geoprompt-0.1.6.tar.gz
- Upload date:
- Size: 35.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2d9f54485f63d0f9c405acec23c5b4821d4346e1fd7bc58ecb63b033a32e9940
|
|
| MD5 |
23527d8704bfb3c29c3c6f1a4d702149
|
|
| BLAKE2b-256 |
592bc8ba63c8b7a218c5e05e40704884f332e554261774ee23f6506d9461b746
|
Provenance
The following attestation bundles were made for geoprompt-0.1.6.tar.gz:
Publisher:
publish-pypi.yml on matthew-lottly/geoprompt
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
geoprompt-0.1.6.tar.gz -
Subject digest:
2d9f54485f63d0f9c405acec23c5b4821d4346e1fd7bc58ecb63b033a32e9940 - Sigstore transparency entry: 1142092417
- Sigstore integration time:
-
Permalink:
matthew-lottly/geoprompt@0edc1dfe3a20ceb52b090ce77aa0f7283126e95c -
Branch / Tag:
refs/tags/v0.1.6 - Owner: https://github.com/matthew-lottly
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@0edc1dfe3a20ceb52b090ce77aa0f7283126e95c -
Trigger Event:
push
-
Statement type:
File details
Details for the file geoprompt-0.1.6-py3-none-any.whl.
File metadata
- Download URL: geoprompt-0.1.6-py3-none-any.whl
- Upload date:
- Size: 29.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
488b4e9388753a3326df78140a131dd7fc0ff4635163357dbe0c4e9e2399b203
|
|
| MD5 |
4bcc792cd76d3f86a218d13ef9fd51d2
|
|
| BLAKE2b-256 |
314c2dd733307f37e8954fb4c43745f3609a1c932e5415d23ed668a0be95392c
|
Provenance
The following attestation bundles were made for geoprompt-0.1.6-py3-none-any.whl:
Publisher:
publish-pypi.yml on matthew-lottly/geoprompt
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
geoprompt-0.1.6-py3-none-any.whl -
Subject digest:
488b4e9388753a3326df78140a131dd7fc0ff4635163357dbe0c4e9e2399b203 - Sigstore transparency entry: 1142092499
- Sigstore integration time:
-
Permalink:
matthew-lottly/geoprompt@0edc1dfe3a20ceb52b090ce77aa0f7283126e95c -
Branch / Tag:
refs/tags/v0.1.6 - Owner: https://github.com/matthew-lottly
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@0edc1dfe3a20ceb52b090ce77aa0f7283126e95c -
Trigger Event:
push
-
Statement type: