constructs an sfc of MULTILINESTRING objects
sfc_multilinestring(
obj = NULL,
x = NULL,
y = NULL,
z = NULL,
m = NULL,
multilinestring_id = NULL,
linestring_id = NULL
)
sorted matrix or data.frame
x geometry column
y geometry column
z geometry column
m geometry column
column of ids for multilinestrings
column of ids for linestrings (within multilinestrings)
sfc
object of MULTILINESTRING geometries
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.
m <- matrix(c(0,0,0,0,1,1), ncol = 3 )
sfc_multilinestring( m )
#> [[1]]
#> [[1]]
#> [,1] [,2] [,3]
#> [1,] 0 0 1
#> [2,] 0 0 1
#>
#> attr(,"class")
#> [1] "XYZ" "MULTILINESTRING" "sfg"
#>
#> attr(,"n_empty")
#> [1] 0
#> attr(,"crs")
#> $input
#> [1] NA
#>
#> $wkt
#> [1] NA
#>
#> attr(,"class")
#> [1] "crs"
#> attr(,"class")
#> [1] "sfc_MULTILINESTRING" "sfc"
#> attr(,"precision")
#> [1] 0
#> attr(,"bbox")
#> xmin ymin xmax ymax
#> 0 0 0 0
#> attr(,"class")
#> [1] "bbox"
#> attr(,"z_range")
#> zmin zmax
#> 1 1
#> attr(,"class")
#> [1] "z_range"
m <- matrix(c(0,0,0,0,0,1,0,1,1,1,2,2,1,2,3), ncol = 3, byrow = TRUE)
sfc_multilinestring( obj = m )
#> [[1]]
#> [[1]]
#> [,1] [,2] [,3]
#> [1,] 0 0 0
#> [2,] 0 0 1
#> [3,] 0 1 1
#> [4,] 1 2 2
#> [5,] 1 2 3
#>
#> attr(,"class")
#> [1] "XYZ" "MULTILINESTRING" "sfg"
#>
#> attr(,"n_empty")
#> [1] 0
#> attr(,"crs")
#> $input
#> [1] NA
#>
#> $wkt
#> [1] NA
#>
#> attr(,"class")
#> [1] "crs"
#> attr(,"class")
#> [1] "sfc_MULTILINESTRING" "sfc"
#> attr(,"precision")
#> [1] 0
#> attr(,"bbox")
#> xmin ymin xmax ymax
#> 0 0 1 2
#> attr(,"class")
#> [1] "bbox"
#> attr(,"z_range")
#> zmin zmax
#> 0 3
#> attr(,"class")
#> [1] "z_range"
sfc_multilinestring( obj = m, multilinestring_id = 1 )
#> [[1]]
#> [[1]]
#> [,1] [,2]
#> [1,] 0 0
#> [2,] 0 1
#> [3,] 1 1
#>
#> attr(,"class")
#> [1] "XY" "MULTILINESTRING" "sfg"
#>
#> [[2]]
#> [[1]]
#> [,1] [,2]
#> [1,] 2 2
#> [2,] 2 3
#>
#> attr(,"class")
#> [1] "XY" "MULTILINESTRING" "sfg"
#>
#> attr(,"n_empty")
#> [1] 0
#> attr(,"crs")
#> $input
#> [1] NA
#>
#> $wkt
#> [1] NA
#>
#> attr(,"class")
#> [1] "crs"
#> attr(,"class")
#> [1] "sfc_MULTILINESTRING" "sfc"
#> attr(,"precision")
#> [1] 0
#> attr(,"bbox")
#> xmin ymin xmax ymax
#> 0 0 2 3
#> attr(,"class")
#> [1] "bbox"
sfc_multilinestring( obj = m, linestring_id = 1 )
#> [[1]]
#> [[1]]
#> [,1] [,2]
#> [1,] 0 0
#> [2,] 0 1
#> [3,] 1 1
#>
#> [[2]]
#> [,1] [,2]
#> [1,] 2 2
#> [2,] 2 3
#>
#> attr(,"class")
#> [1] "XY" "MULTILINESTRING" "sfg"
#>
#> attr(,"n_empty")
#> [1] 0
#> attr(,"crs")
#> $input
#> [1] NA
#>
#> $wkt
#> [1] NA
#>
#> attr(,"class")
#> [1] "crs"
#> attr(,"class")
#> [1] "sfc_MULTILINESTRING" "sfc"
#> attr(,"precision")
#> [1] 0
#> attr(,"bbox")
#> xmin ymin xmax ymax
#> 0 0 2 3
#> attr(,"class")
#> [1] "bbox"
sfc_multilinestring( obj = m, linestring_id = 1, multilinestring_id = 1 )
#> [[1]]
#> [[1]]
#> [,1] [,2]
#> [1,] 0 0
#> [2,] 0 1
#> [3,] 1 1
#>
#> attr(,"class")
#> [1] "XY" "MULTILINESTRING" "sfg"
#>
#> [[2]]
#> [[1]]
#> [,1] [,2]
#> [1,] 2 2
#> [2,] 2 3
#>
#> attr(,"class")
#> [1] "XY" "MULTILINESTRING" "sfg"
#>
#> attr(,"n_empty")
#> [1] 0
#> attr(,"crs")
#> $input
#> [1] NA
#>
#> $wkt
#> [1] NA
#>
#> attr(,"class")
#> [1] "crs"
#> attr(,"class")
#> [1] "sfc_MULTILINESTRING" "sfc"
#> attr(,"precision")
#> [1] 0
#> attr(,"bbox")
#> xmin ymin xmax ymax
#> 0 0 2 3
#> attr(,"class")
#> [1] "bbox"
sfc_multilinestring( obj = m, x = 2, y = 3 )
#> [[1]]
#> [[1]]
#> [,1] [,2]
#> [1,] 0 0
#> [2,] 0 1
#> [3,] 1 1
#> [4,] 2 2
#> [5,] 2 3
#>
#> attr(,"class")
#> [1] "XY" "MULTILINESTRING" "sfg"
#>
#> attr(,"n_empty")
#> [1] 0
#> attr(,"crs")
#> $input
#> [1] NA
#>
#> $wkt
#> [1] NA
#>
#> attr(,"class")
#> [1] "crs"
#> attr(,"class")
#> [1] "sfc_MULTILINESTRING" "sfc"
#> attr(,"precision")
#> [1] 0
#> attr(,"bbox")
#> xmin ymin xmax ymax
#> 0 0 2 3
#> attr(,"class")
#> [1] "bbox"
sfc_multilinestring( obj = m, x = 1, y = 2, z = 3 )
#> [[1]]
#> [[1]]
#> [,1] [,2] [,3]
#> [1,] 0 0 0
#> [2,] 0 0 1
#> [3,] 0 1 1
#> [4,] 1 2 2
#> [5,] 1 2 3
#>
#> attr(,"class")
#> [1] "XYZ" "MULTILINESTRING" "sfg"
#>
#> attr(,"n_empty")
#> [1] 0
#> attr(,"crs")
#> $input
#> [1] NA
#>
#> $wkt
#> [1] NA
#>
#> attr(,"class")
#> [1] "crs"
#> attr(,"class")
#> [1] "sfc_MULTILINESTRING" "sfc"
#> attr(,"precision")
#> [1] 0
#> attr(,"bbox")
#> xmin ymin xmax ymax
#> 0 0 1 2
#> attr(,"class")
#> [1] "bbox"
#> attr(,"z_range")
#> zmin zmax
#> 0 3
#> attr(,"class")
#> [1] "z_range"
sfc_multilinestring( obj = m, x = 2, y = 3, linestring_id = 1, multilinestring_id = 1 )
#> [[1]]
#> [[1]]
#> [,1] [,2]
#> [1,] 0 0
#> [2,] 0 1
#> [3,] 1 1
#>
#> attr(,"class")
#> [1] "XY" "MULTILINESTRING" "sfg"
#>
#> [[2]]
#> [[1]]
#> [,1] [,2]
#> [1,] 2 2
#> [2,] 2 3
#>
#> attr(,"class")
#> [1] "XY" "MULTILINESTRING" "sfg"
#>
#> attr(,"n_empty")
#> [1] 0
#> attr(,"crs")
#> $input
#> [1] NA
#>
#> $wkt
#> [1] NA
#>
#> attr(,"class")
#> [1] "crs"
#> attr(,"class")
#> [1] "sfc_MULTILINESTRING" "sfc"
#> attr(,"precision")
#> [1] 0
#> attr(,"bbox")
#> xmin ymin xmax ymax
#> 0 0 2 3
#> attr(,"class")
#> [1] "bbox"
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)
)
sfc_multilinestring( obj = df, x = "x", y = "y")
#> [[1]]
#> [[1]]
#> [,1] [,2]
#> [1,] -0.4265481 0.03355271
#> [2,] -1.7649720 1.40451705
#> [3,] -1.5775738 0.10182842
#> [4,] 0.4821113 1.22779901
#> [5,] -0.4196557 -1.86697916
#> [6,] 0.4877076 -0.38331130
#> [7,] 0.3871084 0.05269726
#> [8,] 0.1050004 -0.85110417
#> [9,] -0.6866081 -0.65687778
#> [10,] -0.1104188 -0.68395731
#> [11,] 0.2933001 0.49298159
#> [12,] -2.3638442 -0.61778568
#> [13,] -0.2841777 -1.19881923
#>
#> attr(,"class")
#> [1] "XY" "MULTILINESTRING" "sfg"
#>
#> attr(,"n_empty")
#> [1] 0
#> attr(,"crs")
#> $input
#> [1] NA
#>
#> $wkt
#> [1] NA
#>
#> attr(,"class")
#> [1] "crs"
#> attr(,"class")
#> [1] "sfc_MULTILINESTRING" "sfc"
#> attr(,"precision")
#> [1] 0
#> attr(,"bbox")
#> xmin ymin xmax ymax
#> -2.3638442 -1.8669792 0.4877076 1.4045171
#> attr(,"class")
#> [1] "bbox"
sfc_multilinestring( obj = df, x = "x", y = "y", z = "z")
#> [[1]]
#> [[1]]
#> [,1] [,2] [,3]
#> [1,] -0.4265481 0.03355271 -0.41939126
#> [2,] -1.7649720 1.40451705 -1.14743104
#> [3,] -1.5775738 0.10182842 0.97120272
#> [4,] 0.4821113 1.22779901 -0.08037733
#> [5,] -0.4196557 -1.86697916 2.35816628
#> [6,] 0.4877076 -0.38331130 -0.70836002
#> [7,] 0.3871084 0.05269726 0.77481116
#> [8,] 0.1050004 -0.85110417 1.35594124
#> [9,] -0.6866081 -0.65687778 0.71225610
#> [10,] -0.1104188 -0.68395731 -0.97574961
#> [11,] 0.2933001 0.49298159 0.36353954
#> [12,] -2.3638442 -0.61778568 0.42342666
#> [13,] -0.2841777 -1.19881923 -0.23036840
#>
#> attr(,"class")
#> [1] "XYZ" "MULTILINESTRING" "sfg"
#>
#> attr(,"n_empty")
#> [1] 0
#> attr(,"crs")
#> $input
#> [1] NA
#>
#> $wkt
#> [1] NA
#>
#> attr(,"class")
#> [1] "crs"
#> attr(,"class")
#> [1] "sfc_MULTILINESTRING" "sfc"
#> attr(,"precision")
#> [1] 0
#> attr(,"bbox")
#> xmin ymin xmax ymax
#> -2.3638442 -1.8669792 0.4877076 1.4045171
#> attr(,"class")
#> [1] "bbox"
#> attr(,"z_range")
#> zmin zmax
#> -1.147431 2.358166
#> attr(,"class")
#> [1] "z_range"
sfc_multilinestring( obj = df, x = "x", y = "y", z = "z", m = "m")
#> [[1]]
#> [[1]]
#> [,1] [,2] [,3] [,4]
#> [1,] -0.4265481 0.03355271 -0.41939126 0.0249345
#> [2,] -1.7649720 1.40451705 -1.14743104 -1.1129934
#> [3,] -1.5775738 0.10182842 0.97120272 1.5367085
#> [4,] 0.4821113 1.22779901 -0.08037733 0.2090207
#> [5,] -0.4196557 -1.86697916 2.35816628 -1.1120871
#> [6,] 0.4877076 -0.38331130 -0.70836002 0.4237897
#> [7,] 0.3871084 0.05269726 0.77481116 0.3068737
#> [8,] 0.1050004 -0.85110417 1.35594124 -0.2120821
#> [9,] -0.6866081 -0.65687778 0.71225610 -2.2662124
#> [10,] -0.1104188 -0.68395731 -0.97574961 -0.9917302
#> [11,] 0.2933001 0.49298159 0.36353954 -0.7830823
#> [12,] -2.3638442 -0.61778568 0.42342666 -0.2962116
#> [13,] -0.2841777 -1.19881923 -0.23036840 1.6439183
#>
#> attr(,"class")
#> [1] "XYZM" "MULTILINESTRING" "sfg"
#>
#> attr(,"n_empty")
#> [1] 0
#> attr(,"crs")
#> $input
#> [1] NA
#>
#> $wkt
#> [1] NA
#>
#> attr(,"class")
#> [1] "crs"
#> attr(,"class")
#> [1] "sfc_MULTILINESTRING" "sfc"
#> attr(,"precision")
#> [1] 0
#> attr(,"bbox")
#> xmin ymin xmax ymax
#> -2.3638442 -1.8669792 0.4877076 1.4045171
#> attr(,"class")
#> [1] "bbox"
#> attr(,"z_range")
#> zmin zmax
#> -1.147431 2.358166
#> attr(,"class")
#> [1] "z_range"
#> attr(,"m_range")
#> mmin mmax
#> -2.266212 1.643918
#> attr(,"class")
#> [1] "m_range"
sfc_multilinestring( obj = df, x = 2, y = 3)
#> [[1]]
#> [[1]]
#> [,1] [,2]
#> [1,] 1 -0.4265481
#> [2,] 1 -1.7649720
#> [3,] 1 -1.5775738
#> [4,] 2 0.4821113
#> [5,] 2 -0.4196557
#> [6,] 3 0.4877076
#> [7,] 3 0.3871084
#> [8,] 3 0.1050004
#> [9,] 1 -0.6866081
#> [10,] 1 -0.1104188
#> [11,] 1 0.2933001
#> [12,] 2 -2.3638442
#> [13,] 2 -0.2841777
#>
#> attr(,"class")
#> [1] "XY" "MULTILINESTRING" "sfg"
#>
#> attr(,"n_empty")
#> [1] 0
#> attr(,"crs")
#> $input
#> [1] NA
#>
#> $wkt
#> [1] NA
#>
#> attr(,"class")
#> [1] "crs"
#> attr(,"class")
#> [1] "sfc_MULTILINESTRING" "sfc"
#> attr(,"precision")
#> [1] 0
#> attr(,"bbox")
#> xmin ymin xmax ymax
#> 1.0000000 -2.3638442 3.0000000 0.4877076
#> attr(,"class")
#> [1] "bbox"
sfc_multilinestring( obj = df, x = 2, y = 3, z = 4)
#> [[1]]
#> [[1]]
#> [,1] [,2] [,3]
#> [1,] 1 -0.4265481 0.03355271
#> [2,] 1 -1.7649720 1.40451705
#> [3,] 1 -1.5775738 0.10182842
#> [4,] 2 0.4821113 1.22779901
#> [5,] 2 -0.4196557 -1.86697916
#> [6,] 3 0.4877076 -0.38331130
#> [7,] 3 0.3871084 0.05269726
#> [8,] 3 0.1050004 -0.85110417
#> [9,] 1 -0.6866081 -0.65687778
#> [10,] 1 -0.1104188 -0.68395731
#> [11,] 1 0.2933001 0.49298159
#> [12,] 2 -2.3638442 -0.61778568
#> [13,] 2 -0.2841777 -1.19881923
#>
#> attr(,"class")
#> [1] "XYZ" "MULTILINESTRING" "sfg"
#>
#> attr(,"n_empty")
#> [1] 0
#> attr(,"crs")
#> $input
#> [1] NA
#>
#> $wkt
#> [1] NA
#>
#> attr(,"class")
#> [1] "crs"
#> attr(,"class")
#> [1] "sfc_MULTILINESTRING" "sfc"
#> attr(,"precision")
#> [1] 0
#> attr(,"bbox")
#> xmin ymin xmax ymax
#> 1.0000000 -2.3638442 3.0000000 0.4877076
#> attr(,"class")
#> [1] "bbox"
#> attr(,"z_range")
#> zmin zmax
#> -1.866979 1.404517
#> attr(,"class")
#> [1] "z_range"
sfc_multilinestring( obj = df, x = 2, y = 3, z = 4, m = 5)
#> [[1]]
#> [[1]]
#> [,1] [,2] [,3] [,4]
#> [1,] 1 -0.4265481 0.03355271 -0.41939126
#> [2,] 1 -1.7649720 1.40451705 -1.14743104
#> [3,] 1 -1.5775738 0.10182842 0.97120272
#> [4,] 2 0.4821113 1.22779901 -0.08037733
#> [5,] 2 -0.4196557 -1.86697916 2.35816628
#> [6,] 3 0.4877076 -0.38331130 -0.70836002
#> [7,] 3 0.3871084 0.05269726 0.77481116
#> [8,] 3 0.1050004 -0.85110417 1.35594124
#> [9,] 1 -0.6866081 -0.65687778 0.71225610
#> [10,] 1 -0.1104188 -0.68395731 -0.97574961
#> [11,] 1 0.2933001 0.49298159 0.36353954
#> [12,] 2 -2.3638442 -0.61778568 0.42342666
#> [13,] 2 -0.2841777 -1.19881923 -0.23036840
#>
#> attr(,"class")
#> [1] "XYZM" "MULTILINESTRING" "sfg"
#>
#> attr(,"n_empty")
#> [1] 0
#> attr(,"crs")
#> $input
#> [1] NA
#>
#> $wkt
#> [1] NA
#>
#> attr(,"class")
#> [1] "crs"
#> attr(,"class")
#> [1] "sfc_MULTILINESTRING" "sfc"
#> attr(,"precision")
#> [1] 0
#> attr(,"bbox")
#> xmin ymin xmax ymax
#> 1.0000000 -2.3638442 3.0000000 0.4877076
#> attr(,"class")
#> [1] "bbox"
#> attr(,"z_range")
#> zmin zmax
#> -1.866979 1.404517
#> attr(,"class")
#> [1] "z_range"
#> attr(,"m_range")
#> mmin mmax
#> -1.147431 2.358166
#> attr(,"class")
#> [1] "m_range"
sfc_multilinestring( obj = df, multilinestring_id = "ml_id", linestring_id = "l_id" )
#> [[1]]
#> [[1]]
#> [,1] [,2] [,3] [,4]
#> [1,] -0.4265481 0.03355271 -0.4193913 0.0249345
#> [2,] -1.7649720 1.40451705 -1.1474310 -1.1129934
#> [3,] -1.5775738 0.10182842 0.9712027 1.5367085
#>
#> [[2]]
#> [,1] [,2] [,3] [,4]
#> [1,] 0.4821113 1.227799 -0.08037733 0.2090207
#> [2,] -0.4196557 -1.866979 2.35816628 -1.1120871
#>
#> [[3]]
#> [,1] [,2] [,3] [,4]
#> [1,] 0.4877076 -0.38331130 -0.7083600 0.4237897
#> [2,] 0.3871084 0.05269726 0.7748112 0.3068737
#> [3,] 0.1050004 -0.85110417 1.3559412 -0.2120821
#>
#> attr(,"class")
#> [1] "XYZM" "MULTILINESTRING" "sfg"
#>
#> [[2]]
#> [[1]]
#> [,1] [,2] [,3] [,4]
#> [1,] -0.6866081 -0.6568778 0.7122561 -2.2662124
#> [2,] -0.1104188 -0.6839573 -0.9757496 -0.9917302
#> [3,] 0.2933001 0.4929816 0.3635395 -0.7830823
#>
#> [[2]]
#> [,1] [,2] [,3] [,4]
#> [1,] -2.3638442 -0.6177857 0.4234267 -0.2962116
#> [2,] -0.2841777 -1.1988192 -0.2303684 1.6439183
#>
#> attr(,"class")
#> [1] "XYZM" "MULTILINESTRING" "sfg"
#>
#> attr(,"n_empty")
#> [1] 0
#> attr(,"crs")
#> $input
#> [1] NA
#>
#> $wkt
#> [1] NA
#>
#> attr(,"class")
#> [1] "crs"
#> attr(,"class")
#> [1] "sfc_MULTILINESTRING" "sfc"
#> attr(,"precision")
#> [1] 0
#> attr(,"bbox")
#> xmin ymin xmax ymax
#> -2.3638442 -1.8669792 0.4877076 1.4045171
#> attr(,"class")
#> [1] "bbox"
#> attr(,"z_range")
#> zmin zmax
#> -1.147431 2.358166
#> attr(,"class")
#> [1] "z_range"
#> attr(,"m_range")
#> mmin mmax
#> -2.266212 1.643918
#> attr(,"class")
#> [1] "m_range"
sfc_multilinestring( obj = df, multilinestring_id = 1, linestring_id = 2 )
#> [[1]]
#> [[1]]
#> [,1] [,2] [,3] [,4]
#> [1,] -0.4265481 0.03355271 -0.4193913 0.0249345
#> [2,] -1.7649720 1.40451705 -1.1474310 -1.1129934
#> [3,] -1.5775738 0.10182842 0.9712027 1.5367085
#>
#> [[2]]
#> [,1] [,2] [,3] [,4]
#> [1,] 0.4821113 1.227799 -0.08037733 0.2090207
#> [2,] -0.4196557 -1.866979 2.35816628 -1.1120871
#>
#> [[3]]
#> [,1] [,2] [,3] [,4]
#> [1,] 0.4877076 -0.38331130 -0.7083600 0.4237897
#> [2,] 0.3871084 0.05269726 0.7748112 0.3068737
#> [3,] 0.1050004 -0.85110417 1.3559412 -0.2120821
#>
#> attr(,"class")
#> [1] "XYZM" "MULTILINESTRING" "sfg"
#>
#> [[2]]
#> [[1]]
#> [,1] [,2] [,3] [,4]
#> [1,] -0.6866081 -0.6568778 0.7122561 -2.2662124
#> [2,] -0.1104188 -0.6839573 -0.9757496 -0.9917302
#> [3,] 0.2933001 0.4929816 0.3635395 -0.7830823
#>
#> [[2]]
#> [,1] [,2] [,3] [,4]
#> [1,] -2.3638442 -0.6177857 0.4234267 -0.2962116
#> [2,] -0.2841777 -1.1988192 -0.2303684 1.6439183
#>
#> attr(,"class")
#> [1] "XYZM" "MULTILINESTRING" "sfg"
#>
#> attr(,"n_empty")
#> [1] 0
#> attr(,"crs")
#> $input
#> [1] NA
#>
#> $wkt
#> [1] NA
#>
#> attr(,"class")
#> [1] "crs"
#> attr(,"class")
#> [1] "sfc_MULTILINESTRING" "sfc"
#> attr(,"precision")
#> [1] 0
#> attr(,"bbox")
#> xmin ymin xmax ymax
#> -2.3638442 -1.8669792 0.4877076 1.4045171
#> attr(,"class")
#> [1] "bbox"
#> attr(,"z_range")
#> zmin zmax
#> -1.147431 2.358166
#> attr(,"class")
#> [1] "z_range"
#> attr(,"m_range")
#> mmin mmax
#> -2.266212 1.643918
#> attr(,"class")
#> [1] "m_range"