Run the GeoLibre / whitebox_next_gen geospatial tool suite (WASM/WASI) from Python.
Project description
geolibre-wasm (Python)
Run the geolibre-rust geospatial
tool suite (the whitebox_next_gen tools plus GeoLibre's own) from Python. The
tools are a single WebAssembly (WASI) module executed in-process via
wasmtime, so there is no
native install, no GDAL, and no server — just pip install.
This mirrors the JavaScript geolibre-wasm/tools API (list_tools,
list_manifests, run_tool), so the two stay in sync.
The import package is
geolibre_wasm(the distribution isgeolibre-wasm), matching the npm package name and avoiding a clash with the separategeolibreapplication package.
Install
pip install geolibre-wasm
On first use the runtime (geolibre-cli.wasm, ~20 MB) is downloaded from the
matching GitHub release and cached under ~/.cache/geolibre/. To use a local
copy instead, set GEOLIBRE_WASM=/path/to/geolibre-cli.wasm or pass
wasm_path= to any call.
Usage
Inputs are passed as bytes under /work; the tool reads/writes there and any
new files come back as bytes.
Paths are sandboxed. Every path inside
argsrefers to the tool's/workfilesystem, not your host disk.inputfiles are placed at/work/<name>, andres.fileskeys are paths relative to/work. Do your ownopen()/write()against host paths (e.g./content/...on Colab) on the Python side, never insideargs.
import geolibre_wasm as gl
# Discover tools (each manifest carries a "source": "geolibre" | "whitebox")
tools = gl.list_tools()
manifests = gl.list_manifests()
# Raster: compute slope from a DEM
dem = open("dem.tif", "rb").read() # read from host disk
res = gl.run_tool(
"slope",
args=["--input=/work/dem.tif", "--output=/work/slope.tif", "--units=degrees"],
input={"dem.tif": dem}, # -> /work/dem.tif
)
assert res.exit_code == 0, res.stdout # surfaces tool errors
open("slope.tif", "wb").write(res.files["slope.tif"]) # key is relative to /work
# Reproject (warp) to a target EPSG
res = gl.run_tool(
"reproject_raster",
args=["--input=/work/dem.tif", "--output=/work/wgs84.tif", "--epsg=4326"],
input={"dem.tif": dem},
)
# Vector: GeoJSON -> GeoParquet (Hilbert-sorted, bbox covering, ZSTD by default)
gj = open("cities.geojson", "rb").read()
res = gl.run_tool(
"write_geoparquet",
args=["--input=/work/in.geojson", "--output=/work/out.parquet"],
input={"in.geojson": gj},
)
open("cities.parquet", "wb").write(res.files["out.parquet"])
Tools that write a directory tree (e.g. raster_to_tiles) return nested keys:
res = gl.run_tool(
"raster_to_tiles",
args=["--input=/work/dem.tif", "--output_dir=/work/tiles", "--min_zoom=16", "--max_zoom=18"],
input={"dem.tif": dem},
)
for path, data in res.files.items():
# e.g. "tiles/16/9559/32767.png"
...
API
list_tools(wasm_path=None) -> list[str]list_manifests(wasm_path=None) -> list[dict]run_tool(tool, args=None, input=None, wasm_path=None) -> ToolResultToolResult(exit_code: int, stdout: list[str], files: dict[str, bytes])runtime_path(wasm_path=None) -> str— resolve the runtime (explicit >GEOLIBRE_WASM> cached download)download_runtime(dest=None) -> str— fetch the runtime ahead of time
License
MIT
Project details
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 geolibre_wasm-0.4.2.tar.gz.
File metadata
- Download URL: geolibre_wasm-0.4.2.tar.gz
- Upload date:
- Size: 6.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bbf626901ea999b96c9e2f07a4c55f7ecdb39be1eba5f7dedc2954b3a6ea99ff
|
|
| MD5 |
09d29fb80629e6f4e5c08047eb3132f2
|
|
| BLAKE2b-256 |
f729f2f72289c5d8ae2669a837d2c4e39fb83c0e05ca53cb74c9868716af245d
|
Provenance
The following attestation bundles were made for geolibre_wasm-0.4.2.tar.gz:
Publisher:
release.yml on opengeos/geolibre-rust
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
geolibre_wasm-0.4.2.tar.gz -
Subject digest:
bbf626901ea999b96c9e2f07a4c55f7ecdb39be1eba5f7dedc2954b3a6ea99ff - Sigstore transparency entry: 1877306882
- Sigstore integration time:
-
Permalink:
opengeos/geolibre-rust@d0eb8c0ee14557b311ada51afbf693ade286f02c -
Branch / Tag:
refs/tags/v0.4.2 - Owner: https://github.com/opengeos
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@d0eb8c0ee14557b311ada51afbf693ade286f02c -
Trigger Event:
push
-
Statement type:
File details
Details for the file geolibre_wasm-0.4.2-py3-none-any.whl.
File metadata
- Download URL: geolibre_wasm-0.4.2-py3-none-any.whl
- Upload date:
- Size: 7.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ea46d5b96fa39efa783bc03027fbdd6682a78f9833d06b6bdd85c8ba007f69cd
|
|
| MD5 |
6a7b6ce60778c2a34078484cf30c40df
|
|
| BLAKE2b-256 |
8432b6affa61e79942f23bd1af69bd2069df3715f354a7f70b1668d92a9d5133
|
Provenance
The following attestation bundles were made for geolibre_wasm-0.4.2-py3-none-any.whl:
Publisher:
release.yml on opengeos/geolibre-rust
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
geolibre_wasm-0.4.2-py3-none-any.whl -
Subject digest:
ea46d5b96fa39efa783bc03027fbdd6682a78f9833d06b6bdd85c8ba007f69cd - Sigstore transparency entry: 1877307018
- Sigstore integration time:
-
Permalink:
opengeos/geolibre-rust@d0eb8c0ee14557b311ada51afbf693ade286f02c -
Branch / Tag:
refs/tags/v0.4.2 - Owner: https://github.com/opengeos
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@d0eb8c0ee14557b311ada51afbf693ade286f02c -
Trigger Event:
push
-
Statement type: