Skip to contents

post_array is a spatio-temporal array data structure that organises polygons that change their shape in space and time. It extends the stars class for vector data cubes to support changing geometries as attributes. The post_array class supports two dimensions: a summary geometry dimension (default name: geom_sum) and a temporal dimension. The summary geometry is a unique geometry per group which summarises the changing shapes of the polygon geometries in the group.

Usage

as_post_array(
  x,
  group_id = NULL,
  time_column_name = NULL,
  sf_column_name = NULL,
  geometry_summary = summarise_geometry_centroid,
  geometry_summary_name = NULL,
  ...
)

# S3 method for class 'sf'
as_post_array(
  x,
  group_id = NULL,
  time_column_name = NULL,
  sf_column_name = NULL,
  geometry_summary = summarise_geometry_centroid,
  geometry_summary_name = NULL,
  ...,
  point_st = c(TRUE, FALSE)
)

# S3 method for class 'post_table'
as_post_array(x, ...)

# S3 method for class 'post_array'
as_post_array(x, ...)

Arguments

x

object to convert to post_array with POLYGON/MULTIPOLYGON geometries and a date/time column.

group_id

See Details. Defaults to the first non-spatial, non-temporal column in x.

time_column_name

(character) name of column with the temporal dimension information. Defaults to the first temporal column in x.

sf_column_name

(character) name of column with changing geometries. Defaults to active sf_column.

geometry_summary

(function) function to compute the summary geometry. Alternatively an sfc object with summary geometries (i.e., the result of a summarise_geometry_*() function or a custom sfc). See summarise_geometry for functions or pass your own summarise_geometry function.

geometry_summary_name

(character) name of the column with summary geometries.Defaults to "geom_sum"

...

additional parameters passed on to geometry_summary function.

point_st

point argument passed onto stars::st_dimensions(). Defaults to TRUE for the spatial dimension and to FALSE for the temporal dimension (assumes interval times)

Value

an object of class post_array.

Details

group_id should be the name of the column containing the grouping identifier for the changing polygons or a vector with group identifiers. Character, integer, double and factor vectors are supported. The vector should be of length 1 or the same as nrow(x). A vector of length 1 repeats the value for all the rows. Providing a vector assumes that the ordering of the groups is correct and that there are no duplicated timestamps per group

References

Abad, L., Sudmanns, M., and Hölbling, D. (2024) Vector data cubes for features evolving in space and time, AGILE GIScience Ser., 5, 16, https://doi.org/10.5194/agile-giss-5-16-2024

Examples

as_post_array(polygons)
#> stars object with 2 dimensions and 1 attribute
#> attribute(s):
#>          geometry  
#>  POLYGON      :25  
#>  epsg:4326    : 0  
#>  +proj=long...: 0  
#> dimension(s):
#>          from to     offset  delta refsys point
#> geom_sum    1  5         NA     NA WGS 84  TRUE
#> datetime    1  5 2020-10-01 1 days   Date FALSE
#>                                                            values
#> geom_sum POINT (0.647816 0.9018588),...,POINT (0.4690683 0.17772)
#> datetime                                                     NULL

if(require(dplyr, quietly = TRUE)) {
  library(sf, quietly = TRUE)
  polygons |>
    mutate(area = st_area(geometry)) |>
    as_post_array(
     geometry_summary = summarise_geometry_union
   )
}
#> 
#> Attaching package: ‘dplyr’
#> The following objects are masked from ‘package:stats’:
#> 
#>     filter, lag
#> The following objects are masked from ‘package:base’:
#> 
#>     intersect, setdiff, setequal, union
#> Linking to GEOS 3.10.2, GDAL 3.4.1, PROJ 8.2.1; sf_use_s2() is TRUE
#> stars object with 2 dimensions and 2 attributes
#> attribute(s):
#>          geometry       area           
#>  POLYGON      :25   Min.   :5.366e+07  
#>  epsg:4326    : 0   1st Qu.:3.928e+08  
#>  +proj=long...: 0   Median :4.060e+08  
#>                     Mean   :6.216e+08  
#>                     3rd Qu.:6.933e+08  
#>                     Max.   :1.537e+09  
#> dimension(s):
#>          from to     offset  delta refsys point
#> geom_sum    1  5         NA     NA WGS 84 FALSE
#> datetime    1  5 2020-10-01 1 days   Date FALSE
#>                                                                 values
#> geom_sum POLYGON ((0.4971355 0.871...,...,POLYGON ((0.2973931 0.255...
#> datetime                                                          NULL