GVAL (pronounced "g-val") is a high-level Python framework to evaluate the skill of geospatial datasets by comparing candidates to benchmark maps producing agreement maps and metrics.
GVAL is intended to work on raster and vector files as xarray and geopandas objects, respectively. Abilities to prepare or homogenize maps for comparison are included. The comparisons are based on scoring philosophies for three statistical data types including categorical, continuous, and probabilistic.
See the full documentation.
WARNING:
- Our current public API and output formats are likely to change in the future.
- Software is provided "AS-IS" without any guarantees. Please QA/QC your metrics carefully until this project matures.
Installation
General Use
To use this package:
pip install gval
Or for bleeding edge updates install from the repository:
pip install 'git+https://github.com/NOAA-OWP/gval'
Using GVAL
Categorical Example
An example of running the entire process for two-class categorical rasters with one function using minimal arguments is demonstrated below:
import gval
import rioxarray as rxr
candidate = rxr.open_rasterio('candidate_map_two_class_categorical.tif', mask_and_scale=True)
benchmark = rxr.open_rasterio('benchmark_map_two_class_categorical.tif', mask_and_scale=True)
(agreement_map,
crosstab_table,
metric_table) = candidate.gval.categorical_compare(benchmark,
positive_categories=[2],
negative_categories=[0, 1])
Categorical Outputs
agreement_map
crosstab_table
metric_table
Continuous Example
The same can be done for rasters with continuous valued statistical data types as shown below (in this case only a subset of the default statistics will be run):
import gval
import rioxarray as rxr
candidate = rxr.open_rasterio('livneh_2011_precip.tif', mask_and_scale=True) # VIC
benchmark = rxr.open_rasterio('prism_2011_precip.tif', mask_and_scale=True) # PRISM
agreement, metric_table = candidate.gval.continuous_compare(
benchmark,
metrics=[
"coefficient_of_determination",
"mean_percentage_error",
"mean_absolute_percentage_error",
"mean_normalized_mean_absolute_error"
]
)
Continuous Outputs
agreement_map
metric_table
Catalog Example
Entire catalogs can be compared in GVAL, which are represented by dataframes of maps. The following is a candidate and benchmark catalog for continuous datasets:
candidate_catalog
benchmark_catalog
With the following code a comparison of each pair of maps can be run
with the following code. Since the parameter agreement_map_field is
provided the column agreement_maps found in the candidate catalog will
be used to export the agreement map to that location. (Note the first
pair of candidate and benchmark maps are single band rasters while the
second pair are multiband rasters):
import pandas as pd
from gval.catalogs.catalogs import catalog_compare
candidate_continuous_catalog = pd.read_csv('candidate_catalog_0.csv')
benchmark_continuous_catalog = pd.read_csv('benchmark_catalog_0.csv')
arguments = {
"candidate_catalog": candidate_continuous_catalog,
"benchmark_catalog": benchmark_continuous_catalog,
"on": "compare_id",
"agreement_map_field": "agreement_maps",
"map_ids": "map_id",
"how": "inner",
"compare_type": "continuous",
"compare_kwargs": {
"metrics": (
"coefficient_of_determination",
"mean_absolute_error",
"mean_absolute_percentage_error",
),
"encode_nodata": True,
"nodata": -9999,
},
"open_kwargs": {
"mask_and_scale": True,
"masked": True
}
}
agreement_continuous_catalog = catalog_compare(**arguments)
Catalog Outputs
agreement_map
catalog_metrics
(Note that both catalog level attributes in the candidate and benchmark catalogs are present in the catalog metrics table.)
For more detailed examples of how to use this software, check out these notebook tutorials.
Contributing
Guidelines for contributing to this repository can be found at CONTRIBUTING.
Citation
Please cite our work if using this package. See 'cite this repository' in the about section on GitHub or refer to CITATION.cff
Metadata
Release files for gval 0.2.15
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| gval-0.2.15.tar.gz | 78.1 kB | Without provenance | Details for gval-0.2.15.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| gval-0.2.15-py3-none-any.whl | Python 3 | none | any | Details for gval-0.2.15-py3-none-any.whl |
Total release size: 152.1 kB
Release files / gval-0.2.15.tar.gz
| Download URL | gval-0.2.15.tar.gz |
|---|---|
| Size | 78.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
043fe0c07eacc4b75be23b64318ae9b14199d17ea1ac2548103921e7d933a482
|
|
BLAKE2b-256 checksum How to use checksums |
b9582a7cf9f51ab8b674ddec24d28433f15489310d652a569b9b18a4dacb121b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/9.0.0 pkginfo/1.12.1.2 requests/2.34.2 requests-toolbelt/1.0.0 tqdm/4.70.0 CPython/3.12.14
|
Release files / gval-0.2.15-py3-none-any.whl
| Download URL | gval-0.2.15-py3-none-any.whl |
|---|---|
| Size | 74.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b8062a70c83c882395ccfbe430e415fbccb15838dc18f586d19bf0b89c0ba5e7
|
|
BLAKE2b-256 checksum How to use checksums |
d0ee489e0ec805eb6fbb33af00169564459e78e55ea794cd2a562b1ec1331286
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/9.0.0 pkginfo/1.12.1.2 requests/2.34.2 requests-toolbelt/1.0.0 tqdm/4.70.0 CPython/3.12.14
|
Security for gval 0.2.15
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.