Skip to contents

Extract rotation information from raster file

Usage

extract_rotation(df, start_year, tif_name, r_path, lookup, lu_constant = c())

Arguments

df

sf data.frame with land use. "id" and "type" columns should be present.

start_year

numeric, representing a year from which data begins.

tif_name

string for name of .tif raster file.

r_path

string for path to .tif file.

lookup

dataframe with "lc1" column for numeric codes and "type" column for text.

lu_constant

vector of strings with land uses to be kept constant in land use (i.e. water, urban areas, etc.)

Value

sf data.frame with land use amended with crop rotation information

Examples

if (FALSE) {
library(sf)
##Loading land use/crop layer
lu_path <- system.file("extdata", "GIS/lu_layer.shp", package = "svatools")
lu <- st_read(lu_path,  quiet = TRUE) %>% mutate(id = row_number())
##Preparing lookup table
lookup <- data.frame(lc1 = seq(1:length(unique(c(lu$type)))), 
type = unique(c(lu$type)))
lu_constant <- c("fesc", "orch", "frst", "frse", "frsd", "urld", "urhd", 
"wetl", "past", "watr", "agrl")

##Extracting rotation information from raster
##Raster information should have been prepared with remote sensing 
lu_rot <- extract_rotation(lu, 2015, "cropmaps.tif", "./output/", lookup, lu_constant)
}