active {sfdep} | R Documentation |
From a spacetime
object, activate either the data or geometry contexts. The active object will then become available for manipulation.
active(.data)
activate(.data, what)
.data |
a spacetime object |
what |
default NULL. Determines which context to activate. Valid argument values
are |
A spacetime
object contains both a data frame and an sf object. The
data frame represents geographies over one or more time periods and the sf
object contains the geographic information for those locations.
For activate()
an object of class spacetime with the specified context activated. active()
returns a scalar character with the active context can be either "goemetry" or "data".
df_fp <- system.file("extdata", "bos-ecometric.csv", package = "sfdep")
geo_fp <- system.file("extdata", "bos-ecometric.geojson", package = "sfdep")
# read in data
df <- read.csv(
df_fp, colClasses = c("character", "character", "integer", "double", "Date")
)
geo <- sf::st_read(geo_fp)
# Create spacetime object called `bos`
bos <- spacetime(df, geo,
.loc_col = ".region_id",
.time_col = "time_period")
active(bos)
activate(bos, "geometry")