constructs an sfc of MULTILINESTRING objects
Usage
sfc_multilinestring(
obj = NULL,
x = NULL,
y = NULL,
z = NULL,
m = NULL,
multilinestring_id = NULL,
linestring_id = NULL
)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
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.386127022 1.1589792
#> [2,] 0.020831228 -0.2032090
#> [3,] 0.007586777 -0.3780286
#> [4,] 0.930844030 1.7361110
#> [5,] -0.684749941 -0.8452478
#> [6,] 0.337401513 -0.9615715
#> [7,] -0.412137704 1.0174911
#> [8,] 0.934261130 -1.4960537
#> [9,] 1.840316741 -1.1848187
#> [10,] -0.704819663 0.6302344
#> [11,] 0.008510312 2.1012525
#> [12,] 2.034189886 -0.6137368
#> [13,] -1.341686068 -1.6346383
#>
#> 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.341686 -1.634638 2.034190 2.101253
#> attr(,"class")
#> [1] "bbox"
sfc_multilinestring( obj = df, x = "x", y = "y", z = "z")
#> [[1]]
#> [[1]]
#> [,1] [,2] [,3]
#> [1,] 0.386127022 1.1589792 -0.01044112
#> [2,] 0.020831228 -0.2032090 -0.65650614
#> [3,] 0.007586777 -0.3780286 -0.66953344
#> [4,] 0.930844030 1.7361110 -0.47858903
#> [5,] -0.684749941 -0.8452478 1.31945632
#> [6,] 0.337401513 -0.9615715 0.63656276
#> [7,] -0.412137704 1.0174911 0.51432778
#> [8,] 0.934261130 -1.4960537 -1.75137511
#> [9,] 1.840316741 -1.1848187 0.89359752
#> [10,] -0.704819663 0.6302344 0.22303837
#> [11,] 0.008510312 2.1012525 0.58081659
#> [12,] 2.034189886 -0.6137368 -0.17782142
#> [13,] -1.341686068 -1.6346383 0.74096671
#>
#> 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.341686 -1.634638 2.034190 2.101253
#> attr(,"class")
#> [1] "bbox"
#> attr(,"z_range")
#> zmin zmax
#> -1.751375 1.319456
#> 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.386127022 1.1589792 -0.01044112 -0.99744308
#> [2,] 0.020831228 -0.2032090 -0.65650614 -2.93897756
#> [3,] 0.007586777 -0.3780286 -0.66953344 0.71901566
#> [4,] 0.930844030 1.7361110 -0.47858903 -0.69800504
#> [5,] -0.684749941 -0.8452478 1.31945632 -1.89412584
#> [6,] 0.337401513 -0.9615715 0.63656276 0.07629925
#> [7,] -0.412137704 1.0174911 0.51432778 0.87530850
#> [8,] 0.934261130 -1.4960537 -1.75137511 0.45382739
#> [9,] 1.840316741 -1.1848187 0.89359752 -0.85071691
#> [10,] -0.704819663 0.6302344 0.22303837 0.56620161
#> [11,] 0.008510312 2.1012525 0.58081659 1.15221195
#> [12,] 2.034189886 -0.6137368 -0.17782142 -0.75619738
#> [13,] -1.341686068 -1.6346383 0.74096671 -0.48925833
#>
#> 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.341686 -1.634638 2.034190 2.101253
#> attr(,"class")
#> [1] "bbox"
#> attr(,"z_range")
#> zmin zmax
#> -1.751375 1.319456
#> attr(,"class")
#> [1] "z_range"
#> attr(,"m_range")
#> mmin mmax
#> -2.938978 1.152212
#> attr(,"class")
#> [1] "m_range"
sfc_multilinestring( obj = df, x = 2, y = 3)
#> [[1]]
#> [[1]]
#> [,1] [,2]
#> [1,] 1 0.386127022
#> [2,] 1 0.020831228
#> [3,] 1 0.007586777
#> [4,] 2 0.930844030
#> [5,] 2 -0.684749941
#> [6,] 3 0.337401513
#> [7,] 3 -0.412137704
#> [8,] 3 0.934261130
#> [9,] 1 1.840316741
#> [10,] 1 -0.704819663
#> [11,] 1 0.008510312
#> [12,] 2 2.034189886
#> [13,] 2 -1.341686068
#>
#> 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.000000 -1.341686 3.000000 2.034190
#> attr(,"class")
#> [1] "bbox"
sfc_multilinestring( obj = df, x = 2, y = 3, z = 4)
#> [[1]]
#> [[1]]
#> [,1] [,2] [,3]
#> [1,] 1 0.386127022 1.1589792
#> [2,] 1 0.020831228 -0.2032090
#> [3,] 1 0.007586777 -0.3780286
#> [4,] 2 0.930844030 1.7361110
#> [5,] 2 -0.684749941 -0.8452478
#> [6,] 3 0.337401513 -0.9615715
#> [7,] 3 -0.412137704 1.0174911
#> [8,] 3 0.934261130 -1.4960537
#> [9,] 1 1.840316741 -1.1848187
#> [10,] 1 -0.704819663 0.6302344
#> [11,] 1 0.008510312 2.1012525
#> [12,] 2 2.034189886 -0.6137368
#> [13,] 2 -1.341686068 -1.6346383
#>
#> 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.000000 -1.341686 3.000000 2.034190
#> attr(,"class")
#> [1] "bbox"
#> attr(,"z_range")
#> zmin zmax
#> -1.634638 2.101253
#> 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.386127022 1.1589792 -0.01044112
#> [2,] 1 0.020831228 -0.2032090 -0.65650614
#> [3,] 1 0.007586777 -0.3780286 -0.66953344
#> [4,] 2 0.930844030 1.7361110 -0.47858903
#> [5,] 2 -0.684749941 -0.8452478 1.31945632
#> [6,] 3 0.337401513 -0.9615715 0.63656276
#> [7,] 3 -0.412137704 1.0174911 0.51432778
#> [8,] 3 0.934261130 -1.4960537 -1.75137511
#> [9,] 1 1.840316741 -1.1848187 0.89359752
#> [10,] 1 -0.704819663 0.6302344 0.22303837
#> [11,] 1 0.008510312 2.1012525 0.58081659
#> [12,] 2 2.034189886 -0.6137368 -0.17782142
#> [13,] 2 -1.341686068 -1.6346383 0.74096671
#>
#> 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.000000 -1.341686 3.000000 2.034190
#> attr(,"class")
#> [1] "bbox"
#> attr(,"z_range")
#> zmin zmax
#> -1.634638 2.101253
#> attr(,"class")
#> [1] "z_range"
#> attr(,"m_range")
#> mmin mmax
#> -1.751375 1.319456
#> 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.386127022 1.1589792 -0.01044112 -0.9974431
#> [2,] 0.020831228 -0.2032090 -0.65650614 -2.9389776
#> [3,] 0.007586777 -0.3780286 -0.66953344 0.7190157
#>
#> [[2]]
#> [,1] [,2] [,3] [,4]
#> [1,] 0.9308440 1.7361110 -0.478589 -0.698005
#> [2,] -0.6847499 -0.8452478 1.319456 -1.894126
#>
#> [[3]]
#> [,1] [,2] [,3] [,4]
#> [1,] 0.3374015 -0.9615715 0.6365628 0.07629925
#> [2,] -0.4121377 1.0174911 0.5143278 0.87530850
#> [3,] 0.9342611 -1.4960537 -1.7513751 0.45382739
#>
#> attr(,"class")
#> [1] "XYZM" "MULTILINESTRING" "sfg"
#>
#> [[2]]
#> [[1]]
#> [,1] [,2] [,3] [,4]
#> [1,] 1.840316741 -1.1848187 0.8935975 -0.8507169
#> [2,] -0.704819663 0.6302344 0.2230384 0.5662016
#> [3,] 0.008510312 2.1012525 0.5808166 1.1522120
#>
#> [[2]]
#> [,1] [,2] [,3] [,4]
#> [1,] 2.034190 -0.6137368 -0.1778214 -0.7561974
#> [2,] -1.341686 -1.6346383 0.7409667 -0.4892583
#>
#> 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.341686 -1.634638 2.034190 2.101253
#> attr(,"class")
#> [1] "bbox"
#> attr(,"z_range")
#> zmin zmax
#> -1.751375 1.319456
#> attr(,"class")
#> [1] "z_range"
#> attr(,"m_range")
#> mmin mmax
#> -2.938978 1.152212
#> attr(,"class")
#> [1] "m_range"
sfc_multilinestring( obj = df, multilinestring_id = 1, linestring_id = 2 )
#> [[1]]
#> [[1]]
#> [,1] [,2] [,3] [,4]
#> [1,] 0.386127022 1.1589792 -0.01044112 -0.9974431
#> [2,] 0.020831228 -0.2032090 -0.65650614 -2.9389776
#> [3,] 0.007586777 -0.3780286 -0.66953344 0.7190157
#>
#> [[2]]
#> [,1] [,2] [,3] [,4]
#> [1,] 0.9308440 1.7361110 -0.478589 -0.698005
#> [2,] -0.6847499 -0.8452478 1.319456 -1.894126
#>
#> [[3]]
#> [,1] [,2] [,3] [,4]
#> [1,] 0.3374015 -0.9615715 0.6365628 0.07629925
#> [2,] -0.4121377 1.0174911 0.5143278 0.87530850
#> [3,] 0.9342611 -1.4960537 -1.7513751 0.45382739
#>
#> attr(,"class")
#> [1] "XYZM" "MULTILINESTRING" "sfg"
#>
#> [[2]]
#> [[1]]
#> [,1] [,2] [,3] [,4]
#> [1,] 1.840316741 -1.1848187 0.8935975 -0.8507169
#> [2,] -0.704819663 0.6302344 0.2230384 0.5662016
#> [3,] 0.008510312 2.1012525 0.5808166 1.1522120
#>
#> [[2]]
#> [,1] [,2] [,3] [,4]
#> [1,] 2.034190 -0.6137368 -0.1778214 -0.7561974
#> [2,] -1.341686 -1.6346383 0.7409667 -0.4892583
#>
#> 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.341686 -1.634638 2.034190 2.101253
#> attr(,"class")
#> [1] "bbox"
#> attr(,"z_range")
#> zmin zmax
#> -1.751375 1.319456
#> attr(,"class")
#> [1] "z_range"
#> attr(,"m_range")
#> mmin mmax
#> -2.938978 1.152212
#> attr(,"class")
#> [1] "m_range"