Package: lulc-validation
lulc-validationA package to estimate overall accuracy, user's accuracy, and producer's accuracy for a land use / land cover (LULC) map when i) the reference data is generated via a stratified sampling approach, and ii) the strata do not match the map classes.This package is based onStehman, S.V. (2014), Estimating area and map accuracy for stratified random sampling when the strata are different from the map classes.International Journal of Remote Sensing, 35, 13.InstallClone this repo, then pip install locally.pip install .or from PyPi.pip install lulc-validationUseA sample dataset is provided in this repo atdata/samples.csv. This is based on Table. 2 inStehman (2014).Initialise aStratValobject:import pandas as pd
import os
from lulc_validation.lulc_val import StratVal

df = pd.read_csv(os.path.join("data", "samples.csv"))

strat_val = StratVal(
    strata_list=[1, 2, 3, 4], # List of labels for strata.
    class_list=[1, 2, 3, 4], # List of labels for LULC map classes.
    n_strata=[40000, 30000, 20000, 10000], # List of the total number of pixels in each strata.
    samples_df=df, # pandas DataFrame of reference data
    strata_col="stratum", # Column label for strata in `samples_df`
    ref_class="ref_class", # Column label for reference classes in `samples_df`
    map_class="map_class" # Column label for map classes in `samples_df`
)AStratValobject has the following methods:accuracy(): returns a float type number representing the overall accuracy of the LULC map accounting for the stratified sampling design of the reference data. This implementation is based on the worked example of3. Numerical examplesinStehman (2014).users_accuracy(): returns a dict object where keys indicate the map class and values represent user's accuracy for the corresponding class accounting for the stratified sampling design of the reference data. This implementation is based on the worked example of3. Numerical examplesinStehman (2014).producers_accuracy(): returns a dict object where keys indicate the map class and values represent producer's accuracy for the corresponding class accounting for the stratified sampling design of the reference data. This implementation is based on the worked example of3. Numerical examplesinStehman (2014).accuracy_se(): returns the standard error of the estimate of the overall accuracy of the LULC map accounting for the stratified sampling design of the reference data. This implementation is based on the worked example of3. Numerical examplesinStehman (2014).users_accuracy_se(): returns a dict object where keys indicate the map class and values represent standard errors of the estimates of the user's accuracy for the corresponding class accounting for the stratified sampling design of the reference data. This implementation is based on the worked example of3. Numerical examplesinStehman (2014).producers_accuracy_se(): returns a dict object where keys indicate the map class and values represent standard errors of the estimates of the producer's accuracy for the corresponding class accounting for the stratified sampling design of the reference data. This implementation is based on the worked example of3. Numerical examplesinStehman (2014).print(f"accuracy: {strat_val.accuracy()}")
print(f"user's accuracy: {strat_val.users_accuracy()}")
print(f"producer's accuracy: {strat_val.producers_accuracy()}")
print(f"accuracy se: {strat_val.accuracy_se()}")
print(f"user's accuracy se: {strat_val.users_accuracy_se()}")
print(f"producers's accuracy se: {strat_val.producers_accuracy_se()}")Developmentpytest is used for testing and tests are based on replicating calculations in the worked example of3. Numerical examplesinStehman (2014).To run the tests:pytest