constructs sf of POINT objects

sf_point(obj, x = NULL, y = NULL, z = NULL, m = NULL, keep = FALSE)

Arguments

obj

sorted vector, matrix or data.frame

x

x geometry column

y

y geometry column

z

z geometry column

m

m geometry column

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.

Value

sf object of POINT geometries

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.

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.

Examples


x <- c(1:3)
sf_point( x )
#>   geometry
#> 1  1, 2, 3

x <- matrix( c(1:10) , ncol = 2 )
sf_point( x )
#>   geometry
#> 1     1, 6
#> 2     2, 7
#> 3     3, 8
#> 4     4, 9
#> 5    5, 10

x <- setNames( as.data.frame( x ), c("x","y") )
sf_point( x )
#>   geometry
#> 1     1, 6
#> 2     2, 7
#> 3     3, 8
#> 4     4, 9
#> 5    5, 10
sf_point( obj = x, x = "x", y = "y" )
#>   geometry
#> 1     1, 6
#> 2     2, 7
#> 3     3, 8
#> 4     4, 9
#> 5    5, 10
sf_point( obj = x, x = "y", y = "x" )
#>   geometry
#> 1     6, 1
#> 2     7, 2
#> 3     8, 3
#> 4     9, 4
#> 5    10, 5

# keeping properties
x$val <- letters[1:5]
sf_point( x, x = "x", y = "y", keep = TRUE )
#>   val geometry
#> 1   a     1, 6
#> 2   b     2, 7
#> 3   c     3, 8
#> 4   d     4, 9
#> 5   e    5, 10