Skip to main content

Flexible, portable, and efficient geospatial evaluations for a variety of data.

Project description

alt text

Build and TestCoveragePyPI version

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

alt text

crosstab_table

alt text

metric_table

alt text

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

alt text

metric_table

alt text

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

alt text

benchmark_catalog

alt text

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

alt text alt text

catalog_metrics

alt text

(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

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

gval-0.2.7.tar.gz (73.8 kB view details)

Uploaded Source

Built Distribution

gval-0.2.7-py3-none-any.whl (70.5 kB view details)

Uploaded Python 3

File details

Details for the file gval-0.2.7.tar.gz.

File metadata

  • Download URL: gval-0.2.7.tar.gz
  • Upload date:
  • Size: 73.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/7.1.0 pkginfo/1.10.0 requests/2.31.0 requests-toolbelt/1.0.0 tqdm/4.66.2 CPython/3.10.14

File hashes

Hashes for gval-0.2.7.tar.gz
Algorithm Hash digest
SHA256 5721270a41278888c043a3fc1c91c26998799f31edf151a6383afd8e2bd9de9a
MD5 c594f9c6a0b6b0a3db82b797206a6c50
BLAKE2b-256 6044da573573a05426d128d7d78b52d5ef90ee678e1fcbbad5867a53e2168d87

See more details on using hashes here.

File details

Details for the file gval-0.2.7-py3-none-any.whl.

File metadata

  • Download URL: gval-0.2.7-py3-none-any.whl
  • Upload date:
  • Size: 70.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/7.1.0 pkginfo/1.10.0 requests/2.31.0 requests-toolbelt/1.0.0 tqdm/4.66.2 CPython/3.10.14

File hashes

Hashes for gval-0.2.7-py3-none-any.whl
Algorithm Hash digest
SHA256 9c9e1d9710e237a95cbb8385d7c41f21e0e64051fe526985373a2bc80bf5fa87
MD5 31b335cfd56c7c675008f581787a7544
BLAKE2b-256 60000edce46057f5a3ce3de57b23a27613d073424369c99dc1d44a29881ee92b

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page