constructs sf of MULTIPOINT objects

sf_multipoint(
  obj,
  x = NULL,
  y = NULL,
  z = NULL,
  m = NULL,
  multipoint_id = NULL,
  keep = FALSE,
  list_columns = NULL
)

Arguments

obj

sorted matrix or data.frame

x

x geometry column

y

y geometry column

z

z geometry column

m

m geometry column

multipoint_id

column of ids for multipoints

keep

logical indicating if the non-geometry and non-id columns should be kept. if TRUE you must supply the geometry and id columns, and only the first row of each geometry is kept. See Keeping Properties.

list_columns

vector of column names to turn into a list.

Value

sf object of MULTIPOINT geometries

notes

sfheaders functions do not perform any validity checks on the geometries. Nor do they set Coordinate Reference Systems, EPSG, PROJ4 or precision attributes.

The data.frame and matrices you send into the sfheader functions must be ordered.

Keeping Properties

Setting keep = TRUE will retain any columns not specified as a coordinate (x, y, z, m) or an id (e.g., linestring_id, polygon_id) of the input obj.

You can use list_columns to specify which of the properties will be turned into a list, thus keeping all the values in the column. For columns not specified in list_columns, only the first row of the column is kept

The sf_* functions assume the input obj is a long data.frame / matrix, where any properties are repeated down the table for the same geometry.

Examples


x <- matrix( c(1:4), ncol = 2 )
sf_multipoint( x )
#>   id   geometry
#> 1  1 1, 2, 3, 4

x <- data.frame( id = 1:2, x = 1:2, y = 2:1 )
sf_multipoint( x )
#>   id         geometry
#> 1  1 1, 2, 1, 2, 2, 1
sf_multipoint( x, x = "x", y = "y" )
#>   id   geometry
#> 1  1 1, 2, 2, 1
sf_multipoint( x, x = "y", y = "x" )
#>   id   geometry
#> 1  1 2, 1, 1, 2
sf_multipoint( x, multipoint_id = "id", x = "x", y = "y")
#>   id geometry
#> 1  1     1, 2
#> 2  2     2, 1