check_attributes: Check dsmartr input map attributes

View source: R/dsmartr_helpers.R

check_attributesR Documentation

Check dsmartr input map attributes

Description

Checks dsmartr input map attributes for potential data quality issues.

Usage

check_attributes(src_map = NULL, id_field = NULL, cs = NULL, ps = NULL)

Arguments

src_map

An sfc_POLYGON/MULTIPOLYGON or SpatialPolygonsDataFrame object, see dsmartr::prep_polygons().

id_field

String; name of unique feature identifier field.

cs

String; stub of attribute column names holding soil class data

ps

String; stub of attribute column names folding soil percentage data

Details

This function highlights some issues that may cause dsmartr to either fail or behave unpredictably. Usually these are side-effects of prepration work carried out in other software. Sometimes they are the result of errors in the source data. Note that only attributes are checked; geometry checking techniques are already available in sf and other spatial packages. At present, four problems are checked: whether data is missing (e.g. a polygon class without a matching percentage), whether any percentage values are 0%, whether total percentage (by polygon) is not 100%, and whether any IDs are duplicated.

Value

An sf object with appended logical columns indicating presence of possible data faults.

Examples

## Not run: 
load("heronvale_soilmap")
checked_map <- check_attributes(src_map  = heronvale_soilmap,
                                id_field = 'POLY_NO',
                                cs = 'CLASS',
                                ps = 'PERC')

# to write to file without data loss (some formats
# can't store boolean), do this beforehand:
checked_map <- dplyr::mutate_if(checked_map, is.logical, as.character)

## End(Not run)

obrl-soil/dsmartr documentation built on Feb. 1, 2024, 10:57 p.m.