constructs an sf of MULTILINESTRING objects

sf_multilinestring(obj = NULL, x = NULL, y = NULL, z = NULL,
  m = NULL, multilinestring_id = NULL, linestring_id = NULL,
  keep = FALSE)

Arguments

obj

sorted matrix or data.frame

x

x geometry column

y

y geometry column

z

z geometry column

m

m geometry column

multilinestring_id

column of ids for multilinestrings

linestring_id

column of ids for linestrings (within multilinestrings)

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 MULTILINESTRING 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 the first row of any columns not specified as a coordinate (x, y, z, m) or an id (e.g., linestring_id, polygon_id) of the input obj.

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

m <- matrix(c(0,0,0,0,1,1), ncol = 3 ) sf_multilinestring( m )
#> id geometry #> 1 1 0, 0, 0, 0, 1, 1
m <- matrix(c(0,0,0,0,0,1,0,1,1,1,2,2,1,2,3), ncol = 3, byrow = TRUE) sf_multilinestring( obj = m )
#> id geometry #> 1 1 0, 0, 0, 1, 1, 0, 0, 1, 2, 2, 0, 1, 1, 2, 3
sf_multilinestring( obj = m, multilinestring_id = 1 )
#> id geometry #> 1 0 0, 0, 1, 0, 1, 1 #> 2 1 2, 2, 2, 3
sf_multilinestring( obj = m, linestring_id = 1 )
#> id geometry #> 1 1 0, 0, 1, 0, 1, 1, 2, 2, 2, 3
sf_multilinestring( obj = m, linestring_id = 1, multilinestring_id = 1 )
#> id geometry #> 1 0 0, 0, 1, 0, 1, 1 #> 2 1 2, 2, 2, 3
sf_multilinestring( obj = m, x = 2, y = 3 )
#> id geometry #> 1 1 0, 0, 1, 2, 2, 0, 1, 1, 2, 3
sf_multilinestring( obj = m, x = 1, y = 2, z = 3 )
#> id geometry #> 1 1 0, 0, 0, 1, 1, 0, 0, 1, 2, 2, 0, 1, 1, 2, 3
sf_multilinestring( obj = m, x = 2, y = 3, linestring_id = 1, multilinestring_id = 1 )
#> id geometry #> 1 0 0, 0, 1, 0, 1, 1 #> 2 1 2, 2, 2, 3
df <- data.frame( ml_id = c(1,1,1,1,1,1,1,1,2,2,2,2,2) , l_id = c(1,1,1,2,2,3,3,3,1,1,1,2,2) , x = rnorm(13) , y = rnorm(13) , z = rnorm(13) , m = rnorm(13) ) sf_multilinestring( obj = df, x = "x", y = "y")
#> id #> 1 1 #> geometry #> 1 -1.400043517, 0.255317055, -2.437263611, -0.005571287, 0.621552721, 1.148411606, -1.821817661, -0.247325302, -0.244199607, -0.282705449, -0.553699384, 0.628982042, 2.065024895, -1.630989402, 0.512426950, -1.863011492, -0.522012515, -0.052601910, 0.542996343, -0.914074827, 0.468154420, 0.362951256, -1.304543545, 0.737776321, 1.888504929, -0.097445104
sf_multilinestring( obj = df, x = "x", y = "y", z = "z")
#> id #> 1 1 #> geometry #> 1 -1.400043517, 0.255317055, -2.437263611, -0.005571287, 0.621552721, 1.148411606, -1.821817661, -0.247325302, -0.244199607, -0.282705449, -0.553699384, 0.628982042, 2.065024895, -1.630989402, 0.512426950, -1.863011492, -0.522012515, -0.052601910, 0.542996343, -0.914074827, 0.468154420, 0.362951256, -1.304543545, 0.737776321, 1.888504929, -0.097445104, -0.935847354, -0.015950311, -0.826788954, -1.512399651, 0.935363190, 0.176488611, 0.243685465, 1.623548883, 0.112038083, -0.133997013, -1.910087468, -0.279237242, -0.313445978
sf_multilinestring( obj = df, x = "x", y = "y", z = "z", m = "m")
#> id #> 1 1 #> geometry #> 1 -1.400043517, 0.255317055, -2.437263611, -0.005571287, 0.621552721, 1.148411606, -1.821817661, -0.247325302, -0.244199607, -0.282705449, -0.553699384, 0.628982042, 2.065024895, -1.630989402, 0.512426950, -1.863011492, -0.522012515, -0.052601910, 0.542996343, -0.914074827, 0.468154420, 0.362951256, -1.304543545, 0.737776321, 1.888504929, -0.097445104, -0.935847354, -0.015950311, -0.826788954, -1.512399651, 0.935363190, 0.176488611, 0.243685465, 1.623548883, 0.112038083, -0.133997013, -1.910087468, -0.279237242, -0.313445978, 1.067307879, 0.070034850, -0.639123324, -0.049964899, -0.251483443, 0.444797116, 2.755417575, 0.046531380, 0.577709069, 0.118194874, -1.911720491, 0.862086482, -0.243236740
sf_multilinestring( obj = df, x = 3, y = 4)
#> id #> 1 1 #> geometry #> 1 -1.400043517, 0.255317055, -2.437263611, -0.005571287, 0.621552721, 1.148411606, -1.821817661, -0.247325302, -0.244199607, -0.282705449, -0.553699384, 0.628982042, 2.065024895, -1.630989402, 0.512426950, -1.863011492, -0.522012515, -0.052601910, 0.542996343, -0.914074827, 0.468154420, 0.362951256, -1.304543545, 0.737776321, 1.888504929, -0.097445104
sf_multilinestring( obj = df, x = 3, y = 4, z = 5)
#> id #> 1 1 #> geometry #> 1 -1.400043517, 0.255317055, -2.437263611, -0.005571287, 0.621552721, 1.148411606, -1.821817661, -0.247325302, -0.244199607, -0.282705449, -0.553699384, 0.628982042, 2.065024895, -1.630989402, 0.512426950, -1.863011492, -0.522012515, -0.052601910, 0.542996343, -0.914074827, 0.468154420, 0.362951256, -1.304543545, 0.737776321, 1.888504929, -0.097445104, -0.935847354, -0.015950311, -0.826788954, -1.512399651, 0.935363190, 0.176488611, 0.243685465, 1.623548883, 0.112038083, -0.133997013, -1.910087468, -0.279237242, -0.313445978
sf_multilinestring( obj = df, x = 3, y = 4, z = 5, m = 6 )
#> id #> 1 1 #> geometry #> 1 -1.400043517, 0.255317055, -2.437263611, -0.005571287, 0.621552721, 1.148411606, -1.821817661, -0.247325302, -0.244199607, -0.282705449, -0.553699384, 0.628982042, 2.065024895, -1.630989402, 0.512426950, -1.863011492, -0.522012515, -0.052601910, 0.542996343, -0.914074827, 0.468154420, 0.362951256, -1.304543545, 0.737776321, 1.888504929, -0.097445104, -0.935847354, -0.015950311, -0.826788954, -1.512399651, 0.935363190, 0.176488611, 0.243685465, 1.623548883, 0.112038083, -0.133997013, -1.910087468, -0.279237242, -0.313445978, 1.067307879, 0.070034850, -0.639123324, -0.049964899, -0.251483443, 0.444797116, 2.755417575, 0.046531380, 0.577709069, 0.118194874, -1.911720491, 0.862086482, -0.243236740
sf_multilinestring( obj = df, multilinestring_id = "ml_id", linestring_id = "l_id" )
#> ml_id #> 1 1 #> 2 2 #> geometry #> 1 -1.400043517, 0.255317055, -2.437263611, -1.630989402, 0.512426950, -1.863011492, -0.935847354, -0.015950311, -0.826788954, 1.067307879, 0.070034850, -0.639123324, -0.005571287, 0.621552721, -0.522012515, -0.052601910, -1.512399651, 0.935363190, -0.049964899, -0.251483443, 1.148411606, -1.821817661, -0.247325302, 0.542996343, -0.914074827, 0.468154420, 0.176488611, 0.243685465, 1.623548883, 0.444797116, 2.755417575, 0.046531380 #> 2 -0.2441996, -0.2827054, -0.5536994, 0.3629513, -1.3045435, 0.7377763, 0.1120381, -0.1339970, -1.9100875, 0.5777091, 0.1181949, -1.9117205, 0.6289820, 2.0650249, 1.8885049, -0.0974451, -0.2792372, -0.3134460, 0.8620865, -0.2432367
sf_multilinestring( obj = df, multilinestring_id = 1, linestring_id = 2 )
#> id #> 1 1 #> 2 2 #> geometry #> 1 -1.400043517, 0.255317055, -2.437263611, -1.630989402, 0.512426950, -1.863011492, -0.935847354, -0.015950311, -0.826788954, 1.067307879, 0.070034850, -0.639123324, -0.005571287, 0.621552721, -0.522012515, -0.052601910, -1.512399651, 0.935363190, -0.049964899, -0.251483443, 1.148411606, -1.821817661, -0.247325302, 0.542996343, -0.914074827, 0.468154420, 0.176488611, 0.243685465, 1.623548883, 0.444797116, 2.755417575, 0.046531380 #> 2 -0.2441996, -0.2827054, -0.5536994, 0.3629513, -1.3045435, 0.7377763, 0.1120381, -0.1339970, -1.9100875, 0.5777091, 0.1181949, -1.9117205, 0.6289820, 2.0650249, 1.8885049, -0.0974451, -0.2792372, -0.3134460, 0.8620865, -0.2432367