spacetime {sfdep}R Documentation

Construct a spacetime object

Description

A spacetime object is a collection of a linked data frame and an sf objects. It can be thought of as geography linked to a table that represents those geographies over one or more time periods.

Usage

spacetime(.data, .geometry, .loc_col, .time_col, active = "data")

new_spacetime(.data, .geometry, .loc_col, .time_col, active = "data")

validate_spacetime(.data, .geometry, .loc_col, .time_col)

is_spacetime(x, ...)

is.spacetime(x, ...)

Arguments

.data

an object with base class data.frame containing location and time identifiers .loc_col and .time_col respectively.

.geometry

an sf object with columns .loc_col and .time_col

.loc_col

the quoted name of the column containing unique location identifiers. Must be present in both .data and .geometry.

.time_col

the quoted name of the column containing time periods must be present .data. See details for more

active

default "data". The object to make active. See activate() for more.

x

an object to test

...

unused

Details

Create a spacetime representation of vector data from a data.frame and an sf object with spacetime()

.time_col must be able to be sorted. As such, .time_col cannot be a character vector. It must have a base type of (typeof()) either double or integer—the case in dates or factors respectively. An edge case exists with POSIXlt class objects as these can be sorted appropriately but have a base type of list.

spacetime() is a wrapper around new_spacetime(). Spacetimes are validated before creation with validate_spacetime().

Check if an object is a spacetime object with is_spacetime() or is.spacetime().

Value

Validation

validate_spacetime() checks both .data and .geometry to ensure that the constructed spacetime object meets minimum requirements.:

Examples


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)

bos <- spacetime(df, geo, ".region_id", "year")
is_spacetime(bos)
bos



[Package sfdep version 0.2.4 Index]