This function prepares training points for a remote sensing algorithm based on land use and crop classes.
Usage
get_lu_points(
df,
year,
lookup,
lu_constant = c(),
nb_pts = 100,
col_name = "type"
)
Arguments
- df
An sf data.frame with land use. The "type" column should be present.
- year
A numeric value representing the year of land use.
- lookup
A dataframe with a "lc1" column for numeric codes and a "type" column for text.
- lu_constant
(optional) A vector of strings with land uses to be kept constant in land use (e.g., water, urban areas, etc.). Default
lu_constant = c()
.- nb_pts
(optional) A numeric value representing the number of points per land use/crop class. Default
nb_pts = 100
.- col_name
A string with the name of the column to be used representing the type of crops/land use. Default
col_name = "type"
.
References
Mészáros, J., & Szabó, B. (2022). Script to derive and apply crop classification based on Sentinel 1 satellite radar images in Google Earth Engine platform. https://doi.org/10.5281/zenodo.6700122
Examples
if (FALSE) {
library(sf)
# Loading land use/crop layer
lu_path <- system.file("extdata", "GIS/lu_layer.shp", package = "SWATprepR")
lu <- st_read(lu_path, quiet = TRUE)
# Preparing lookup table
lookup <- data.frame(lc1 = seq(1:length(unique(c(lu$type)))),
type = unique(c(lu$type)))
# Setting land uses to be kept constant
lu_constant <- c("fesc", "orch", "frst", "frse", "frsd", "urld", "urhd",
"wetl", "past", "watr", "agrl")
# Getting training points
pts <- get_lu_points(lu, 2021, lookup, lu_constant)
}