This package implements the LUC Calculus for reasoning about land use change events. Based on a set of classified time series, we build expressions to answer specific questions, such as Which events of "Forest" areas were replaced by "Pasture"?
With package "lucC" is possible to build questions using Allen's interval temporal logic relationships and also others extended from their study. I suggest the reader read (Allen 1983) and (Allen 1984) for more details. Besides, is possible to generate graphics with event information and plot maps with results. Using these events the user can to perform analysis on time series data to discover important land use changes.
wtss is an R client package for handling Web Time-Series Service (WTSS) in the client side at https://github.com/e-sensing/wtss.R
Classification method can be found using package dtwSat at https://github.com/vwmaus/dtwSat
Tools to Satellite Image Time Series analysis can be found using package sits at https://github.com/gilbertocamara/sits
install.packages("devtools")
library(devtools)
install_github("ammaciel/lucC")
Load the lucC package library(lucC)
Load a example data data("example_TWDTW")
Create new variable tibble format and apply lucC_standard_date_events to standardize start_date and end_date columns
lucC_starting_point() data_tb <- example_TWDTW %>% lucC_standard_date_events(data_tb = ., month_year = "09", day_month = "01") %>% dplyr::select(longitude, latitude, start_date, end_date, label, id, index) data_tb
lucC_plot_maps_input(data_tb, EPSG_WGS84 = TRUE, custom_palette = TRUE, RGB_color = c( "#FFB266", "#1b791f", "#929e6e", "#f5e7a1"))
Fig. 1. Plot time series classified data
# p = properties of locations : p1 <- "Pasture" # t = interval: t1 <- lucC_interval("2000-09-01","2017-03-01") # Test holds for many time series question_holds <- function(data.tb){ aux.df = NULL if (nrow(event2 <- lucC_predicate_holds(data.tb, p1, t1)) >= 1) aux.df <- event2 else aux.df <- NULL data.frame(aux.df) } temp.tb <- data_tb output.tb = data.frame(do.call("rbind", parallel::mclapply( X = split(temp.tb, temp.tb$index), mc.cores=1, #parallel::detectCores(), FUN = question_holds))) output.tb
See example_1.tb plot with lucC_plot_maps_input function lucC_plot_maps_input(data_tb, EPSG_WGS84 = TRUE, custom_palette = TRUE, RGB_color = c("#FFB266", "#1b791f", "#929e6e","#f5e7a1"))
See all events with lucC_plot_maps_events function lucC_plot_maps_events(output.tb, EPSG_WGS84 = TRUE, custom_palette = TRUE, RGB_color = c("#FFB266", "#1b791f", "#929e6e","#f5e7a1"), shape_point = 0, colour_point = "black", size_point = 2.3)
Fig. 2. Plot events discovered from time series classified data
lucC_plot_bar_events(output.tb, custom_palette = TRUE, RGB_color = "#929e6e", pixel_resolution = 231.6564, side_by_side = FALSE)
and sequence plot lucC_plot_sequence_events(output.tb, end_date = "2017-03-01", custom_palette = TRUE, RGB_color = "#929e6e", show_y_index = FALSE)
# load library library(lucC) lucC_starting_point() # load data example data("example_TWDTW") example_TWDTW # alter start_date and end_date to a especific range in order to extract events # because we work with annual intervals # select only one time serie with index equals 13 data_tb <- example_TWDTW %>% lucC_standard_date_events(data_tb = ., month_year = "09", day_month = "01") %>% dplyr::select(longitude, latitude, start_date, end_date, label, id, index) %>% dplyr::filter(., .$index == 13) data_tb # p = properties of locations : p1 <- "Forest" p2 <- "Pasture" # t = interval: t1 <- lucC_interval("2000-09-01","2004-09-01") t2 <- lucC_interval("2004-09-01","2017-09-01") # Test holds for one time serie question_holds <- function(data.tb){ aux.df = NULL if (nrow(ev1 <- lucC_predicate_holds(data.tb, p1, t1)) >= 1 & nrow(ev2 <- lucC_predicate_holds(data.tb, p2, t2)) >= 1 ){ if(nrow(ev1) != 0 & nrow(ev2) != 0){ if(isTRUE(lucC_relation_meets(tail(lucC_interval(ev1$start_date, ev1$end_date), 1), head(lucC_interval(ev2$start_date, ev2$end_date), 1)))) aux.df <- rbind(ev1,ev2) } else aux.df <- NULL } else { aux.df <- NULL } data.frame(aux.df) } temp.tb <- data_tb output.tb2 = data.frame(do.call("rbind", parallel::mclapply( X = split(temp.tb, temp.tb$index), mc.cores=1, #parallel::detectCores(), FUN = question_holds))) output.tb2
View example_2.tb plot with lucC_plot_maps_input function lucC_plot_maps_input(data_tb, EPSG_WGS84 = TRUE, custom_palette = TRUE, RGB_color = c("#FFB266", "#1b791f", "#929e6e"))
View all events with lucC_plot_maps_events function lucC_plot_maps_events(output.tb2, EPSG_WGS84 = TRUE, custom_palette = TRUE, RGB_color = c("#FFB266", "#1b791f", "#929e6e"), shape_point = 4, colour_point = "blue", size_point = 8)
# load library library(lucC) lucC_starting_point() # load data example data("example_TWDTW") example_TWDTW # alter start_date and end_date to a especific range in order to extract events # because we work with annual intervals data_tb <- example_TWDTW %>% lucC_standard_date_events(data_tb = ., month_year = "09", day_month = "01") %>% dplyr::select(longitude, latitude, start_date, end_date, label, id, index) data_tb # p = properties of locations : p1 <- c("Forest", "Pasture", "Single_cropping", "Double_cropping") # t = interval: t1 <- lucC_interval("2000-09-01","2017-09-01") # Test holds for one time serie question_holds <- function(data.tb){ aux.df = NULL aux.df <- lucC_event_transitions(data.tb, properties = p1, time_intervals = t1) data.frame(aux.df) } temp.tb <- data_tb output.tb3 = data.frame(do.call("rbind", parallel::mclapply( X = split(temp.tb, temp.tb$index), mc.cores=1, #parallel::detectCores(), FUN = question_holds))) output.tb3
See plot with lucC_plot_maps_input function lucC_plot_maps_input(data_tb, EPSG_WGS84 = TRUE, custom_palette = TRUE, RGB_color = c("#FFB266", "#1b791f", "#929e6e","#f5e7a1"))
View all events with lucC_plot_maps_events function lucC_plot_maps_events(output.tb3, EPSG_WGS84 = TRUE, custom_palette = TRUE, RGB_color = c("#FFB266", "#1b791f", "#929e6e","#f5e7a1"), shape_point = 0, colour_point = "blue", size_point = 2.3)
Fig. 5. Plot events discovered from time series classified data
lucC_plot_bar_events(output.tb3, custom_palette = TRUE, RGB_color = c("#FFB266", "#1b791f", "#929e6e","#f5e7a1"), pixel_resolution = 250, side_by_side = FALSE)
and sequence plot lucC_plot_sequence_events(output.tb3, show_y_index = FALSE, end_date = "2017-03-01", custom_palette = TRUE, RGB_color = c("#FFB266", "#1b791f", "#929e6e","#f5e7a1"), relabel = FALSE, original_labels = c("Double_cropping", "Forest", "Pasture", "Single_cropping"), new_labels = c("DC","F","P","SC"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.