Metadata-Version: 2.4
Name: honua-sdk
Version: 0.5.1
Summary: Python SDK for Honua geospatial server -- feature queries, geocoding, and protocol clients
Project-URL: Homepage, https://honua.io
Project-URL: Documentation, https://honua-io.github.io/honua-sdk-python/latest/
Project-URL: Repository, https://github.com/honua-io/honua-sdk-python
Project-URL: Issues, https://github.com/honua-io/honua-sdk-python/issues
Author: Honua
License-Expression: Apache-2.0
License-File: LICENSE
Keywords: geospatial,gis,grpc,honua,mobile,offline,sync
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Scientific/Engineering :: GIS
Classifier: Typing :: Typed
Requires-Python: >=3.11
Requires-Dist: anyio>=4.0.0
Requires-Dist: httpx>=0.27.0
Provides-Extra: all
Requires-Dist: duckdb>=1.0.0; extra == 'all'
Requires-Dist: folium>=0.16.0; extra == 'all'
Requires-Dist: geopandas>=0.14.0; extra == 'all'
Requires-Dist: grpcio>=1.70.0; extra == 'all'
Requires-Dist: lonboard>=0.10.0; extra == 'all'
Requires-Dist: mapclassify>=2.6.0; extra == 'all'
Requires-Dist: polars>=1.0.0; extra == 'all'
Requires-Dist: protobuf>=5.29.0; extra == 'all'
Requires-Dist: pyarrow>=15.0.0; extra == 'all'
Requires-Dist: pyproj>=3.6.0; extra == 'all'
Requires-Dist: rasterio>=1.3.0; extra == 'all'
Requires-Dist: rioxarray>=0.15.0; extra == 'all'
Requires-Dist: shapely>=2.0.0; extra == 'all'
Requires-Dist: websockets>=12.0; extra == 'all'
Requires-Dist: xarray>=2024.1.0; extra == 'all'
Requires-Dist: zarr>=3.0.0; extra == 'all'
Provides-Extra: analytics
Requires-Dist: duckdb>=1.0.0; extra == 'analytics'
Requires-Dist: polars>=1.0.0; extra == 'analytics'
Requires-Dist: pyarrow>=15.0.0; extra == 'analytics'
Provides-Extra: arrow
Requires-Dist: pyarrow>=15.0.0; extra == 'arrow'
Provides-Extra: geometry
Requires-Dist: pyproj>=3.6.0; extra == 'geometry'
Requires-Dist: shapely>=2.0.0; extra == 'geometry'
Provides-Extra: geopandas
Requires-Dist: geopandas>=0.14.0; extra == 'geopandas'
Requires-Dist: shapely>=2.0.0; extra == 'geopandas'
Provides-Extra: grpc
Requires-Dist: grpcio>=1.70.0; extra == 'grpc'
Requires-Dist: protobuf>=5.29.0; extra == 'grpc'
Provides-Extra: raster
Requires-Dist: rasterio>=1.3.0; extra == 'raster'
Requires-Dist: rioxarray>=0.15.0; extra == 'raster'
Requires-Dist: xarray>=2024.1.0; extra == 'raster'
Provides-Extra: realtime
Requires-Dist: websockets>=12.0; extra == 'realtime'
Provides-Extra: viz
Requires-Dist: folium>=0.16.0; extra == 'viz'
Requires-Dist: geopandas>=0.14.0; extra == 'viz'
Requires-Dist: lonboard>=0.10.0; extra == 'viz'
Requires-Dist: mapclassify>=2.6.0; extra == 'viz'
Requires-Dist: shapely>=2.0.0; extra == 'viz'
Provides-Extra: zarr
Requires-Dist: xarray>=2024.1.0; extra == 'zarr'
Requires-Dist: zarr>=3.0.0; extra == 'zarr'
Description-Content-Type: text/markdown

# honua-sdk

> **Native application path:** [gRPC for live data and edits; PMTiles, GeoParquet and COG through the CDN](https://github.com/honua-io/honua-sdk-python/blob/trunk/docs/native-data-paths.md). Start there for native Python gRPC setup, signed private URLs and regeneration after changes. OGC API and GeoServices REST examples below are compatibility workflows.

Python client for [Honua Server](https://github.com/honua-io/honua-server),
the multi-protocol geospatial server behind [Honua](https://honua.io) --
query geospatial features, geocode addresses, stream data over gRPC, and
convert results to GeoDataFrames. Sync and async clients included.

> **Status: Alpha (`0.x`).** APIs may change before 1.0. Breaking changes to
> the public API are gated by a
> [compatibility snapshot](https://github.com/honua-io/honua-sdk-python/blob/trunk/docs/compatibility.md)
> and a per-capability
> [SDK coverage snapshot](https://github.com/honua-io/honua-sdk-python/blob/trunk/docs/sdk-coverage.md).

See the [monorepo README](https://github.com/honua-io/honua-sdk-python) for
the full documentation index, install matrix, and release notes.

## Highlights

- Sync and async clients (`HonuaClient`, `AsyncHonuaClient`) with shared retry,
  refreshable-auth, and error-handling behavior.
- Source-bound facade (`client.source(...)`) returns normalized features across
  GeoServices FeatureServer, OGC API Features, STAC, and OData.
- Protocol wrappers for FeatureServer/MapServer/ImageServer/GeometryServer,
  SceneServer, ElevationServer,
  OGC Features/Maps/Tiles/Coverages/Processes/Records, STAC, WCS 2.0, WFS, WMS,
  WMTS, OData, COG (`CogSession` / `client.cog()`), and geocoding.
- Optional `geopandas` extra converts query responses to GeoDataFrames in one
  call via `honua_sdk.geopandas`; the `raster` extra adds raster result
  interop (`rasterio` / `rioxarray` / `xarray`) and `CogWindowData.to_numpy()` /
  `to_rioxarray()`.

## Raster & Coverage Capability Matrix

| Surface | Support | Entrypoints |
| --- | --- | --- |
| Cloud-Optimized GeoTIFF (COG) | Read-window ✓ · Managed tiles ✓ · Support matrix ✓ | `CogSession`, `AsyncCogSession`, `client.cog()` |
| OGC API Coverages | Discovery ✓ · Domain/Range ✓ · Typed `get_coverage` ✓ · 413/429 budgets ✓ | `client.ogc_coverages()`, `CoveragesClient` |
| WCS 2.0.1 | `GetCapabilities` ✓ · `DescribeCoverage` ✓ · `GetCoverage` ✓ · OWS/413 errors ✓ | `client.wcs(service_id)`, `WcsClient` |
| GeoTIFF / xarray Interop | `open_geotiff` ✓ · `geotiff_to_xarray` ✓ · `xarray_to_geotiff` ✓ | `honua_sdk.raster` (`honua-sdk[raster]`) |
- Optional `grpc` extra unlocks streaming feature queries through
  `honua_sdk.grpc.HonuaGrpcClient` / `HonuaGrpcAsyncClient`.
- The package ships the `honua` CLI for services, layers, style application,
  and sanitized `doctor` diagnostic bundles.

## Install

```bash
pip install honua-sdk                   # core data-plane client
pip install "honua-sdk[geopandas]"      # + GeoDataFrame helpers
pip install "honua-sdk[grpc]"           # + streaming gRPC client
pip install "honua-sdk[raster]"         # + raster interop (rasterio/rioxarray/xarray)
pip install "honua-sdk[grpc,geopandas,raster]"  # everything
```

Requires Python 3.11+.

Install extras from the same package index and with the same version constraints
as the core SDK. For a reproducible release, pin the same SDK version in each
command; an older Git tag would replace the installed package with that version.

## Minimal Example

The examples read the public, anonymous demo server at `https://demo.honua.io`
and its `maui-zoning` FeatureServer (layer `2`: zoning polygons with
`zone_code`, `zone_dist`, `cp_area` and `island`). To use your own server,
change the base URL, service and layer.

```python
from honua_sdk import HonuaClient, Query, SourceDescriptor, SourceLocator

with HonuaClient("https://demo.honua.io") as client:
    source = client.source(
        SourceDescriptor(
            id="maui-zoning",
            protocol="geoservices-feature-service",
            locator=SourceLocator(service_id="maui-zoning", layer_id=2),
        )
    )
    result = source.query(Query(where="island = 'Maui'", out_fields=["*"]))
    print(f"Found {len(result.features)} features")
    for feature in result.features[:3]:
        print(feature.id, feature.properties)

    # Requires the [geopandas] extra
    gdf = result.to_geodataframe()  # GeoDataFrame with geometry column + CRS set
```

The same `SourceDescriptor` with a different `protocol` (`ogc-features`,
`stac`, `odata`, ...) returns the same normalized `Result` shape.

Always use the `with HonuaClient(...) as client:` form -- it guarantees the
underlying `httpx` connections are returned to the pool on exit, even when a
request raises.

### Async

```python
import asyncio

from honua_sdk import AsyncHonuaClient, Query, SourceDescriptor, SourceLocator

async def main() -> None:
    async with AsyncHonuaClient("https://demo.honua.io") as client:
        source = client.source(
            SourceDescriptor(
                id="maui-zoning",
                protocol="geoservices-feature-service",
                locator=SourceLocator(service_id="maui-zoning", layer_id=2),
            )
        )
        result = await source.query(Query(where="island = 'Maui'", out_fields=["*"]))
        print(f"Found {len(result.features)} features")
        async for feature in source.stream(Query(where="zone_code = '929'")):  # parks
            print(feature.id, feature.properties)


asyncio.run(main())
```

Works with FastAPI, asyncio pipelines, Jupyter, and any other async
framework. `asyncio.run(main())` is for scripts; Jupyter and IPython already run
an event loop, where `asyncio.run` raises `RuntimeError`, so call
`await main()` in a notebook cell instead. Sync and async clients share identical method names, retry, and
error-handling behavior.

Protocol IDs follow the canonical cross-SDK names
(`geoservices-feature-service`, `ogc-features`, `stac`, `odata`, ...). Common
aliases (`feature-server`, `featureserver`, `ogc-api-features`, ...) are
accepted and normalized through `honua_sdk.normalize_protocol(...)`.

## Server capability baseline

This SDK requires a Honua Server that advertises these capabilities in its
capability manifest:

- `discovery.capability-manifest`
- `serve.geoservices-featureserver`
- `serve.ogc-api-features`

All three ship in Honua Server's first published release, so that release is
the minimum supported server (`minimumServerVersion: first-release`). The
machine-readable declaration is
[`release/sdk-capability-baseline.json`](https://github.com/honua-io/honua-sdk-python/blob/trunk/release/sdk-capability-baseline.json);
the Honua platform release reads it at the source revision this package was
built from to decide which server versions this SDK is certified against.

## Documentation

Rendered docs site:
[honua-io.github.io/honua-sdk-python](https://honua-io.github.io/honua-sdk-python/latest/).
Platform docs: [honua.io](https://honua.io) and
[honua.gitbook.io/honuaio](https://honua.gitbook.io/honuaio/).

- [5-Minute Quickstart](https://github.com/honua-io/honua-sdk-python/blob/trunk/docs/quickstart.md)
- [Core Client](https://github.com/honua-io/honua-sdk-python/blob/trunk/docs/core-client.md)
- [Protocol Examples](https://github.com/honua-io/honua-sdk-python/blob/trunk/docs/protocol-examples.md)
- [Authentication](https://github.com/honua-io/honua-sdk-python/blob/trunk/docs/auth.md)
- [Geospatial ETL demo](https://github.com/honua-io/honua-sdk-python/blob/trunk/examples/geospatial_etl/README.md)
- [Troubleshooting](https://github.com/honua-io/honua-sdk-python/blob/trunk/docs/troubleshooting.md)
- [Sanitized diagnostic bundles](https://github.com/honua-io/honua-sdk-python/blob/trunk/docs/diagnostic-bundles.md)
- [Monorepo README](https://github.com/honua-io/honua-sdk-python) -- install matrix, package overview, and release notes

Related: [honua-admin](https://github.com/honua-io/honua-sdk-python/tree/trunk/packages/honua-admin)
(control-plane client),
[honua-sdk-js](https://github.com/honua-io/honua-sdk-js) (JS/TS SDKs + MCP server),
[honua-sdk-dotnet](https://github.com/honua-io/honua-sdk-dotnet) (.NET SDKs).

## Verify a release

From 0.2.1, each PyPI release is built by this repository's publication workflow, which attaches
the same wheel and sdist to the matching GitHub release and records a build-provenance attestation
for them. 0.2.0 was published without an attestation; use 0.2.1 or later when you need to verify
provenance. The example verifies the 0.3.3 wheel from PyPI using public attestations.
Run it in Bash with Python 3, pip, and GitHub CLI (tested with 2.103.3).
No GitHub login or token is required. For another release, update both the
version and the expected source commit to match that release.

<!-- BEGIN GENERATED ATTESTATION EXAMPLE -->
```bash
(
  set -eu
  workdir="$(mktemp -d)"
  trap 'rm -r "$workdir"' EXIT
  cd "$workdir"

  version=0.3.3
  repo=honua-io/honua-sdk-python
  source=21a9ecb952e43ecc1450384e595259b1912f27b3
  wheel="honua_sdk-${version}-py3-none-any.whl"
  python3 -m pip download --only-binary=:all: --no-deps "honua-sdk==$version"

  python3 - "$wheel" "$repo" <<'PYTHON' > attestations.jsonl
import hashlib
import json
import sys
from pathlib import Path
from urllib.request import urlopen

wheel, repo = sys.argv[1:]
digest = hashlib.sha256(Path(wheel).read_bytes()).hexdigest()
with urlopen(f"https://api.github.com/repos/{repo}/attestations/sha256:{digest}", timeout=30) as response:
    attestations = json.load(response)["attestations"]
for attestation in attestations:
    print(json.dumps(attestation["bundle"]))
PYTHON

  gh attestation verify "$wheel" --bundle attestations.jsonl --repo "$repo" --source-digest "$source"
)
```
<!-- END GENERATED ATTESTATION EXAMPLE -->

## License

Apache-2.0
