Python client library for WCPS (OGC Web Coverage Processing Service) backends.
Project description
Overview
The OGC Web Coverage Processing Service (WCPS) standard defines a protocol-independent declarative query language for the extraction, processing, and analysis of multi-dimensional coverages (datacubes) representing sensor, image, or statistics data.
This Python library allows to dynamically build WCPS queries and execute on a WCPS server.
Installation
pip install wcps
Examples
Derive an NDVI map from red and near-infrared bands of a Sentinel-2 datacube, threshold the very green areas (values greater than 0.5) as true values (white in a PNG), and save the result as a PNG image.
from wcps.service import Service
from wcps.model import Datacube
# Let S2_L2A be a 3D coverage with nir and red bands;
# slice it at "2025-01-15" on the time axis, getting a 2D map
cov = Datacube("S2_L2A")["time", "2025-01-15"]
# NDVI formula
ndvi = (cov.nir - cov.red) / (cov.nir + cov.red)
# threshold NDVI values to highlight areas with high vegetation
vegetation = ndvi > 0.5
# encode final result to PNG
query = vegetation.encode("PNG")
service = Service("https://ows.rasdaman.org/rasdaman/ows")
# execute the query on the server and get back the response
result = service.execute(query)
# similar to above, but automatically convert the PNG result
# to a numpy array
result = service.execute(query, convert_to_numpy=True)
# alternatively, save the content of the response into a file
service.download(query, output_file='vegetation.png')
We can calculate the average NDVI as follows:
cov = ...
# NDVI formula
ndvi = (cov.nir - cov.red) / (cov.nir + cov.red)
# get average NDVI value
query = ndvi.avg()
service = ...
result = service.execute(query)
print(f'The average NDVI is {result.value}')
A more advanced expression is the general condenser (aggregation) operation. The example calculates the maximum values across all time slices from a 3D datacube between "2015-01-01" and "2015-07-01" for which the average is greater than 20:
from wcps.model import Datacube, AxisIter, Condense, CondenseOp
from wcps.service import Service
cov = Datacube("AvgTemperatureColorScaled")
ansi_iter = (AxisIter("ansi_iter", "ansi")
.of_geo_axis(cov["ansi" : "2015-01-01" : "2015-07-01"]))
max_map = (Condense(CondenseOp.MAX)
.over(ansi_iter)
.where(cov["ansi": ansi_iter.ref()].avg() > 20)
.using(cov["ansi": ansi_iter.ref()]))
query = max_map.encode("PNG")
service = Service("https://ows.rasdaman.org/rasdaman/ows")
service.download(query, 'max_map.png')
Contributing
The directory structure is as follows:
wcps- the main library codetests- testing codedocs- documentation in reStructuredText format
Tests
To run the tests:
# install dependencies
pip install wcps[tests]
pytest
Documentation
To build the documentation:
# install dependencies
pip install wcps[docs]
cd docs
make html
The built documentation can be found in the docs/_build/html/ subdir.
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 wcps-0.2.0.tar.gz.
File metadata
- Download URL: wcps-0.2.0.tar.gz
- Upload date:
- Size: 28.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
51c318b15c32203340188bca4c2bf87125c8c6ad8b385d23c715b5a8abdd0de4
|
|
| MD5 |
bd9c36493244eff44894e66e75f7da4f
|
|
| BLAKE2b-256 |
230c247d1fead9514656daa526692d1b949cd4869e8056b220ff846190fb4559
|
Provenance
The following attestation bundles were made for wcps-0.2.0.tar.gz:
Publisher:
release.yml on rasdaman/wcps-python-client
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
wcps-0.2.0.tar.gz -
Subject digest:
51c318b15c32203340188bca4c2bf87125c8c6ad8b385d23c715b5a8abdd0de4 - Sigstore transparency entry: 163010299
- Sigstore integration time:
-
Permalink:
rasdaman/wcps-python-client@6a3c43b39333a3eeed3c868947a81443198cd86f -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/rasdaman
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@6a3c43b39333a3eeed3c868947a81443198cd86f -
Trigger Event:
push
-
Statement type:
File details
Details for the file wcps-0.2.0-py3-none-any.whl.
File metadata
- Download URL: wcps-0.2.0-py3-none-any.whl
- Upload date:
- Size: 24.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9ddd3639570d258656c0c130ca1b6208d29a3cd4ce7ec4f794a23592c0937c4c
|
|
| MD5 |
32b386c28577bbdc4d810bbb2524cdad
|
|
| BLAKE2b-256 |
9cf9cdf19b3e551abb15c34afcb979fb7b3f4fc6527e72baf896502a3ea3e062
|
Provenance
The following attestation bundles were made for wcps-0.2.0-py3-none-any.whl:
Publisher:
release.yml on rasdaman/wcps-python-client
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
wcps-0.2.0-py3-none-any.whl -
Subject digest:
9ddd3639570d258656c0c130ca1b6208d29a3cd4ce7ec4f794a23592c0937c4c - Sigstore transparency entry: 163010302
- Sigstore integration time:
-
Permalink:
rasdaman/wcps-python-client@6a3c43b39333a3eeed3c868947a81443198cd86f -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/rasdaman
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@6a3c43b39333a3eeed3c868947a81443198cd86f -
Trigger Event:
push
-
Statement type: