GeoGremlin
Bunch of geo related stuff.
- makes polygons orthogonal
- resolves geometries overlaps
- download tiles from wms based on shape
- etc.
Install
# vector only
pip install "geo-gremlin[vector]"
# raster only
pip install "geo-gremlin[raster]"
# CLI tools
pip install "geo-gremlin[cli]"
# all in
pip install "geo-gremlin[vector,raster,cli]"
If you need GDAL-based helpers (like run_gdal_retiling, gdal_imread), install GDAL in two steps:
- Install system GDAL separately (for example via
brewon macOS orconda). - Install Python bindings with the same version as your system GDAL to avoid ABI/version mismatch:
CLI
WMS tile operations
geo-gremlin install-bash-completion
Install bash compeltion for CLI into ~/.bashrc file.
Run it once after install.
geo-gremlin download_wms_tiles
geo-gremlin download_wms_tiles \
WMS_SERVER \
ZOOM_LEVEL \
BOUNDS_FN \
OUTPUT_DIR \
[--n-workers=100] \
[--first-n-tiles=N] \
[--wld-suffix=.wld]
Download map tiles intersecting a GeoJSON boundary. Tiles outside the exact boundary are masked, and a world file is created for every downloaded image. Tiles are loaded in EPSG:3857 projection (web-mercator).
geo-gremlin download_wms_tiles \
"esri" \
19 \
data/test-wms/bounds.geojson \
./test
This creates the downloaded tiles in test/esri_19/.
Parameters:
WMS_SERVER: tile provider:"esri","google","bing","yandex", or"mapbox".ZOOM_LEVEL: zoom level used to select tiles,19is usually the best you can get.BOUNDS_FN: path to a vector file defining the download boundary as Polygon feature.OUTPUT_DIR: parent directory for the generated<server>_<zoom>folder.--n-workers: number of concurrent download workers. Defaults to100.--first-n-tiles: optionally limit the number of downloaded tiles.--wld-suffix: suffix used for generated world files. Defaults to.wld.
geo-gremlin merge_wms_tiles
geo-gremlin merge-wms-tiles \
INPUT_DIR \
[--output=OUTPUT_TIF] \
[--crs=EPSG:3857]
Merge georeferenced PNG or WebP tiles into a single GeoTIFF.
geo-gremlin merge-wms-tiles test/esri_19/
When --output is omitted, this example creates test/esri_19.tif.
Parameters:
INPUT_DIR: directory containing image tiles and their world files.--output: output GeoTIFF path. By default, a.tiffile is created alongside the input directory.--crs: coordinate reference system assigned to the output. Defaults toEPSG:3857.
Requires GDAL and its Python bindings.
geo-gremlin retile_wms_tiles
geo-gremlin retile-wms-tiles \
INPUT_DIR \
OUTPUT_DIR \
[--tile-width=512] \
[--tile-height=512] \
[--tile-overlap=0] \
[--tile-base-name=tile]
Retile georeferenced PNG tiles into uniformly sized tiles. Empty tiles are removed, and partial edge tiles are padded to the requested dimensions.
geo-gremlin retile-wms-tiles \
test/esri_19/ \
test/esri_19_retiled/
Parameters:
INPUT_DIR: directory containing PNG tiles and their world files.OUTPUT_DIR: directory where the retiled PNG files will be created.--tile-width: output tile width in pixels. Defaults to512.--tile-height: output tile height in pixels. Defaults to512.--tile-overlap: overlap between adjacent tiles in pixels. Defaults to0.--tile-base-name: base name used for generated tiles. Defaults totile.
Requires GDAL and its Python bindings.
API
Vector operations
orthogonalize(...)
orthogonalize(
gdf: gpd.GeoDataFrame,
*,
n_workers: int = 6,
verbose: bool = False,
) -> gpd.GeoDataFrame
Orthogonalize all polygon geometries in a GeoDataFrame. It is a batch wrapper over orthogonalize_poly, with optional multiprocessing.
from geo_gremlin.vector.ortho import orthogonalize
ortho_gdf = orthogonalize(overlap_gdf, n_workers=1, verbose=False)
Parameters:
gdf:gpd.GeoDataFrame, input GeoDataFrame with polygon geometries.n_workers:int, number of worker processes (1runs sequentially).verbose:bool, show progress bars whenTrue.
resolve_overlaps(...)
resolve_overlaps(
gdf: gpd.GeoDataFrame,
mode: ResolveMode = "union",
verbose: bool = False,
**params,
) -> gpd.GeoDataFrame
Resolve intersecting polygons in a GeoDataFrame by grouping overlaps and merging them using a selected mode.
from geo_gremlin.vector.overlap import resolve_overlaps
overlap_gdf = resolve_overlaps(test_gdf, mode="union", verbose=False)
Parameters:
gdf:gpd.GeoDataFrame, input GeoDataFrame with polygon geometries.mode:ResolveMode, merge strategy:"union","intersection","largest", or"iou_select".verbose:bool, show progress bars whenTrue.**params: extra params for mode-specific behavior (iou_thresholdfor"iou_select").
Check demo_vector.py.
Dev
For dev dependencies check requirements.txt.
Release files for geo-gremlin 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| geo_gremlin-0.1.0.tar.gz | 23.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| geo_gremlin-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 48.9 kB
Release files / geo_gremlin-0.1.0.tar.gz
| Download URL | geo_gremlin-0.1.0.tar.gz |
|---|---|
| Size | 23.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
db81d7dac2b3b30f37853b4af3de0aab7a8e035c379038a5e38cd908c2341150
|
|
BLAKE2b-256 checksum How to use checksums |
ff94c3ff290584b688a52fd1d05b6353b53d23ce0d1fd9169650646f5e9ec41a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.4
|
Release files / geo_gremlin-0.1.0-py3-none-any.whl
| Download URL | geo_gremlin-0.1.0-py3-none-any.whl |
|---|---|
| Size | 25.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c74b537c13b5fcc00b4bbba6b99b9a927c7a74bd375b04cb3fdcb6691f78720c
|
|
BLAKE2b-256 checksum How to use checksums |
d687145fac59dd93607d9397410388f752a5afdf8406751ed2e11d162badd6cd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.4
|