Gdptools Pygeoapi Plugin
Project description
Gdptools Pygeoapi Plugin
Overview
This package provides two components for working with gdptools area-weighted aggregation via pygeoapi:
- Server-side Plugin (
gdptools_pygeoapi_plugin) - OGC API Processes for pygeoapi that expose gdptools functionality as web services - Python Client (
gdptools_pygeoapi_client) - A lightweight Python client library for interacting with the GDP pygeoapi processes
The plugin supports two data catalog types:
- ClimateR Catalog - OpenDAP-based access using the climateR-catalogs parquet file
- NHGF STAC Catalog - Zarr-based access using the USGS NHGF STAC API
Features
- Weight Calculation - Generate grid-to-polygon intersection weights for climate data aggregation
- Aggregation - Run area-weighted aggregation using pre-computed weights
- Dual Catalog Support - Access data via ClimateR (OpenDAP) or NHGF STAC (Zarr) catalogs
- Async Job Support - Submit long-running jobs and poll for completion
- Weight Caching - Automatically cache computed weights locally to avoid redundant calculations
- Batch Processing - Process multiple GeoDataFrames in parallel
Requirements
- Python 3.10 - 3.12
- pygeoapi >= 0.14.0
- gdptools > 0.2.15
- geopandas >= 0.13
- pandas >= 1.5
Installation
You can install Gdptools Pygeoapi Plugin via pip from PyPI:
pip install gdptools-pygeoapi-plugin
Quick Start (Client Usage)
Using ClimateR Catalog
from gdptools_pygeoapi_client import GDPClient
import geopandas as gpd
import pandas as pd
# Load your polygons
gdf = gpd.read_file("my_watersheds.shp")
# Load a climate catalog (e.g., from climateR-catalogs)
catalog_url = "https://github.com/mikejohnson51/climateR-catalogs/releases/download/June-2024/catalog.parquet"
cat = pd.read_parquet(catalog_url)
# Build catalog dictionary for TerraClimate variables
cat_dict = {
"aet": cat.query("id == 'terraclim' & variable == 'aet'").to_dict(orient="records")[0],
"pet": cat.query("id == 'terraclim' & variable == 'pet'").to_dict(orient="records")[0],
}
# Initialize client (defaults to production endpoint)
client = GDPClient()
# Calculate weights using ClimateR catalog (automatically cached)
weights = client.calc_weights_climr(
gdf=gdf,
cat_dict=cat_dict,
shape_crs=4326,
shape_poly_idx="OBJECTID",
wght_gen_proj=6931,
start_date="1980-01-01",
end_date="1980-12-31",
)
# Run aggregation using ClimateR catalog
results = client.calc_agg_climr(
gdf=gdf,
weights=weights,
cat_dict=cat_dict,
shape_crs=4326,
shape_poly_idx="OBJECTID",
start_date="1980-01-01",
end_date="1980-12-31",
)
print(results.head())
Using NHGF STAC Catalog
from gdptools_pygeoapi_client import GDPClient
import geopandas as gpd
# Load your polygons
gdf = gpd.read_file("my_watersheds.shp")
# Initialize client
client = GDPClient()
# Calculate weights using NHGF STAC catalog
weights = client.calc_weights_stac(
gdf=gdf,
collection_id="gridmet-tmax", # STAC collection ID
variables=["tmax"], # List of variables
shape_crs=4326,
shape_poly_idx="OBJECTID",
wght_gen_proj=6931,
start_date="2020-01-01",
end_date="2020-12-31",
)
# Run aggregation using NHGF STAC catalog
results = client.calc_agg_stac(
gdf=gdf,
weights=weights,
collection_id="gridmet-tmax",
variables=["tmax"],
shape_crs=4326,
shape_poly_idx="OBJECTID",
start_date="2020-01-01",
end_date="2020-12-31",
)
print(results.head())
Usage
Please see the Usage section for detailed documentation on both the server plugin and client library.
Contributing
Contributions are very welcome. To learn more, see docs/contributing.md.
License
Distributed under the terms of the CC0 1.0 Universal license, Gdptools Pygeoapi Plugin is free and open source software.
Issues
If you encounter any problems, please file an issue along with a detailed description.
Credits
This project was generated from @chill's Pygeoapi Plugin Cookiecutter template.
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 gdptools_pygeoapi_plugin-0.0.14.tar.gz.
File metadata
- Download URL: gdptools_pygeoapi_plugin-0.0.14.tar.gz
- Upload date:
- Size: 22.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.2.1 CPython/3.12.12 Linux/5.15.167.4-microsoft-standard-WSL2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e878b157d7d082fab77348352d3869870ef4debb9a7e62c48aa02cb09c9ed605
|
|
| MD5 |
4f194ba5f4df68a690f876067b14449a
|
|
| BLAKE2b-256 |
f0697f07524d62b61d5d7f46fac69e390145d1e9550c1556e83ad002c9b8f530
|
File details
Details for the file gdptools_pygeoapi_plugin-0.0.14-py3-none-any.whl.
File metadata
- Download URL: gdptools_pygeoapi_plugin-0.0.14-py3-none-any.whl
- Upload date:
- Size: 33.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.2.1 CPython/3.12.12 Linux/5.15.167.4-microsoft-standard-WSL2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4bf0f595f112636b72a5e6a3dd931ca4dfdf8e6881f234e61c81c05a27a39e09
|
|
| MD5 |
3c38aba46b08da9bfe96f72fe161cf1d
|
|
| BLAKE2b-256 |
d09c2a62cd132108b61eb96d9318b13d15aa86f577ba20bebeb927f9c7abe256
|