sf_aggregate_lst: Aggregates sf from a list of event

Description Usage Arguments Details Value Examples

View source: R/sf_aggregate_lst.R

Description

Tidy the data and merges data accordingly to a time range and by the values concerned by a split/merge/rename event and return a sf data frame for the time range imputed.

Usage

1
sf_aggregate_lst(df_sf, history_lst, from, to = "2018-12-31")

Arguments

df_sf

A sf data frame containing at least the variables admin1, geometry and admin2 if 'history_lst' contains complex event

history_lst

A list containing a list of event, each code with a slot after, a slot before, a slotevent (split/merge/rename/ complex merge/complex split) and a slot year.

from

Initial date of the time range selected for the admin1 definition, of the class Date, character or numeric.

to

Final date of the time range selected for the admin1 definition, of the class Date, character or numeric, by default "2018-12-31"

Details

For each 'split event', the geometry of the variables contained in the slot 'after' is combined and rename by the variable in the slot 'before'. For each 'rename event', the variable contained in the slot 'after' is renamed. In the new rows, <NA> will be added in the other column than 'sel' and 'geometry'

Value

A object of the same class as df_sf in which all the variables and geometry that needed to be aggregated or renamed (according to the time range) are changed.

Examples

1
2
3
4
5
6
7
# to have the list of split/merge/rename event for Vietnam
vn_history <- dictionary::vn_history

vn_prov04 <- gadmVN::gadm(date = "2004-01-01")
names(vn_prov04)[1] <- "admin1"
vn_prov70 <- sf_aggregate_lst(vn_prov04, vn_history, from = "1970",
                              to = "2004")

choisy/sptools documentation built on Aug. 22, 2019, 12:57 p.m.