Aliases: sfc_polygon
Keywords:
### ** Examples m <- matrix(c(0,0,0,0,1,1), ncol = 2 ) sfc_polygon( m )
[[1]] [[1]] [,1] [,2] [1,] 0 0 [2,] 0 1 [3,] 0 1 [4,] 0 0 attr(,"class") [1] "XY" "POLYGON" "sfg" attr(,"n_empty") [1] 0 attr(,"crs") $input [1] NA $wkt [1] NA attr(,"class") [1] "crs" attr(,"class") [1] "sfc_POLYGON" "sfc" attr(,"precision") [1] 0 attr(,"bbox") xmin ymin xmax ymax 0 0 0 1 attr(,"class") [1] "bbox"
m <- matrix(c(0,0,0,0,0,1,0,1,1,1,2,2,1,2,3,1,3,2), ncol = 3, byrow = TRUE) sfc_polygon( 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 [6,] 1 3 2 [7,] 0 0 0 attr(,"class") [1] "XYZ" "POLYGON" "sfg" attr(,"n_empty") [1] 0 attr(,"crs") $input [1] NA $wkt [1] NA attr(,"class") [1] "crs" attr(,"class") [1] "sfc_POLYGON" "sfc" attr(,"precision") [1] 0 attr(,"bbox") xmin ymin xmax ymax 0 0 1 3 attr(,"class") [1] "bbox" attr(,"z_range") zmin zmax 0 3 attr(,"class") [1] "z_range"
sfc_polygon( obj = m, polygon_id = 1 )
[[1]] [[1]] [,1] [,2] [1,] 0 0 [2,] 0 1 [3,] 1 1 [4,] 0 0 attr(,"class") [1] "XY" "POLYGON" "sfg" [[2]] [[1]] [,1] [,2] [1,] 2 2 [2,] 2 3 [3,] 3 2 [4,] 2 2 attr(,"class") [1] "XY" "POLYGON" "sfg" attr(,"n_empty") [1] 0 attr(,"crs") $input [1] NA $wkt [1] NA attr(,"class") [1] "crs" attr(,"class") [1] "sfc_POLYGON" "sfc" attr(,"precision") [1] 0 attr(,"bbox") xmin ymin xmax ymax 0 0 3 3 attr(,"class") [1] "bbox"
sfc_polygon( obj = m, linestring_id = 1 )
[[1]] [[1]] [,1] [,2] [1,] 0 0 [2,] 0 1 [3,] 1 1 [4,] 0 0 [[2]] [,1] [,2] [1,] 2 2 [2,] 2 3 [3,] 3 2 [4,] 2 2 attr(,"class") [1] "XY" "POLYGON" "sfg" attr(,"n_empty") [1] 0 attr(,"crs") $input [1] NA $wkt [1] NA attr(,"class") [1] "crs" attr(,"class") [1] "sfc_POLYGON" "sfc" attr(,"precision") [1] 0 attr(,"bbox") xmin ymin xmax ymax 0 0 3 3 attr(,"class") [1] "bbox"
sfc_polygon( obj = m, linestring_id = 1, polygon_id = 1 )
[[1]] [[1]] [,1] [,2] [1,] 0 0 [2,] 0 1 [3,] 1 1 [4,] 0 0 attr(,"class") [1] "XY" "POLYGON" "sfg" [[2]] [[1]] [,1] [,2] [1,] 2 2 [2,] 2 3 [3,] 3 2 [4,] 2 2 attr(,"class") [1] "XY" "POLYGON" "sfg" attr(,"n_empty") [1] 0 attr(,"crs") $input [1] NA $wkt [1] NA attr(,"class") [1] "crs" attr(,"class") [1] "sfc_POLYGON" "sfc" attr(,"precision") [1] 0 attr(,"bbox") xmin ymin xmax ymax 0 0 3 3 attr(,"class") [1] "bbox"
sfc_polygon( 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 [6,] 3 2 [7,] 0 0 attr(,"class") [1] "XY" "POLYGON" "sfg" attr(,"n_empty") [1] 0 attr(,"crs") $input [1] NA $wkt [1] NA attr(,"class") [1] "crs" attr(,"class") [1] "sfc_POLYGON" "sfc" attr(,"precision") [1] 0 attr(,"bbox") xmin ymin xmax ymax 0 0 3 3 attr(,"class") [1] "bbox"
sfc_polygon( 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 [6,] 1 3 2 [7,] 0 0 0 attr(,"class") [1] "XYZ" "POLYGON" "sfg" attr(,"n_empty") [1] 0 attr(,"crs") $input [1] NA $wkt [1] NA attr(,"class") [1] "crs" attr(,"class") [1] "sfc_POLYGON" "sfc" attr(,"precision") [1] 0 attr(,"bbox") xmin ymin xmax ymax 0 0 1 3 attr(,"class") [1] "bbox" attr(,"z_range") zmin zmax 0 3 attr(,"class") [1] "z_range"
sfc_polygon( obj = m, x = 2, y = 3, linestring_id = 1, polygon_id = 1 )
[[1]] [[1]] [,1] [,2] [1,] 0 0 [2,] 0 1 [3,] 1 1 [4,] 0 0 attr(,"class") [1] "XY" "POLYGON" "sfg" [[2]] [[1]] [,1] [,2] [1,] 2 2 [2,] 2 3 [3,] 3 2 [4,] 2 2 attr(,"class") [1] "XY" "POLYGON" "sfg" attr(,"n_empty") [1] 0 attr(,"crs") $input [1] NA $wkt [1] NA attr(,"class") [1] "crs" attr(,"class") [1] "sfc_POLYGON" "sfc" attr(,"precision") [1] 0 attr(,"bbox") xmin ymin xmax ymax 0 0 3 3 attr(,"class") [1] "bbox"
df <- data.frame( ml_id = c(1,1,1,1,1,1,1,1,1,2,2,2,2,2,2) , l_id = c(1,1,1,2,2,2,3,3,3,1,1,1,2,2,2) , x = rnorm(15) , y = rnorm(15) , z = rnorm(15) , m = rnorm(15) ) sfc_polygon( obj = df, x = "x", y = "y")
[[1]] [[1]] [,1] [,2] [1,] 1.7444893 0.4826674 [2,] 2.5508583 -1.0474812 [3,] -0.7329064 0.2879019 [4,] 0.7389258 -0.6532391 [5,] 1.8459791 -0.1153225 [6,] 0.5551210 -0.4613806 [7,] -0.1483135 1.4460091 [8,] -0.2362459 1.2497721 [9,] 0.3755072 0.1414420 [10,] -1.4042598 -1.5065652 [11,] 1.0330866 1.0734309 [12,] -1.1282957 0.3948881 [13,] -0.1655074 -3.6519185 [14,] 0.1725528 0.5483315 [15,] 0.6400153 -0.1047943 [16,] 1.7444893 0.4826674 attr(,"class") [1] "XY" "POLYGON" "sfg" attr(,"n_empty") [1] 0 attr(,"crs") $input [1] NA $wkt [1] NA attr(,"class") [1] "crs" attr(,"class") [1] "sfc_POLYGON" "sfc" attr(,"precision") [1] 0 attr(,"bbox") xmin ymin xmax ymax -1.404260 -3.651918 2.550858 1.446009 attr(,"class") [1] "bbox"
sfc_polygon( obj = df, x = "x", y = "y", z = "z")
[[1]] [[1]] [,1] [,2] [,3] [1,] 1.7444893 0.4826674 -0.37887602 [2,] 2.5508583 -1.0474812 -0.67905602 [3,] -0.7329064 0.2879019 -1.63413260 [4,] 0.7389258 -0.6532391 0.46286628 [5,] 1.8459791 -0.1153225 0.41299686 [6,] 0.5551210 -0.4613806 0.72507844 [7,] -0.1483135 1.4460091 0.71304228 [8,] -0.2362459 1.2497721 -0.19217631 [9,] 0.3755072 0.1414420 0.62974467 [10,] -1.4042598 -1.5065652 -1.31013409 [11,] 1.0330866 1.0734309 -0.42148644 [12,] -1.1282957 0.3948881 -0.09475231 [13,] -0.1655074 -3.6519185 0.52279297 [14,] 0.1725528 0.5483315 -3.05068074 [15,] 0.6400153 -0.1047943 -0.20019534 [16,] 1.7444893 0.4826674 -0.37887602 attr(,"class") [1] "XYZ" "POLYGON" "sfg" attr(,"n_empty") [1] 0 attr(,"crs") $input [1] NA $wkt [1] NA attr(,"class") [1] "crs" attr(,"class") [1] "sfc_POLYGON" "sfc" attr(,"precision") [1] 0 attr(,"bbox") xmin ymin xmax ymax -1.404260 -3.651918 2.550858 1.446009 attr(,"class") [1] "bbox" attr(,"z_range") zmin zmax -3.0506807 0.7250784 attr(,"class") [1] "z_range"
sfc_polygon( obj = df, x = "x", y = "y", z = "z", m = "m")
[[1]] [[1]] [,1] [,2] [,3] [,4] [1,] 1.7444893 0.4826674 -0.37887602 0.77309722 [2,] 2.5508583 -1.0474812 -0.67905602 0.64517632 [3,] -0.7329064 0.2879019 -1.63413260 0.07160540 [4,] 0.7389258 -0.6532391 0.46286628 -1.63020333 [5,] 1.8459791 -0.1153225 0.41299686 0.04752034 [6,] 0.5551210 -0.4613806 0.72507844 -0.33390857 [7,] -0.1483135 1.4460091 0.71304228 0.08296710 [8,] -0.2362459 1.2497721 -0.19217631 -0.95271218 [9,] 0.3755072 0.1414420 0.62974467 -0.90642566 [10,] -1.4042598 -1.5065652 -1.31013409 0.57492297 [11,] 1.0330866 1.0734309 -0.42148644 -1.05267421 [12,] -1.1282957 0.3948881 -0.09475231 0.78531897 [13,] -0.1655074 -3.6519185 0.52279297 -1.27170217 [14,] 0.1725528 0.5483315 -3.05068074 -0.22200486 [15,] 0.6400153 -0.1047943 -0.20019534 1.14869562 [16,] 1.7444893 0.4826674 -0.37887602 0.77309722 attr(,"class") [1] "XYZM" "POLYGON" "sfg" attr(,"n_empty") [1] 0 attr(,"crs") $input [1] NA $wkt [1] NA attr(,"class") [1] "crs" attr(,"class") [1] "sfc_POLYGON" "sfc" attr(,"precision") [1] 0 attr(,"bbox") xmin ymin xmax ymax -1.404260 -3.651918 2.550858 1.446009 attr(,"class") [1] "bbox" attr(,"z_range") zmin zmax -3.0506807 0.7250784 attr(,"class") [1] "z_range" attr(,"m_range") mmin mmax -1.630203 1.148696 attr(,"class") [1] "m_range"
sfc_polygon( obj = df, x = 2, y = 3)
[[1]] [[1]] [,1] [,2] [1,] 1 1.7444893 [2,] 1 2.5508583 [3,] 1 -0.7329064 [4,] 2 0.7389258 [5,] 2 1.8459791 [6,] 2 0.5551210 [7,] 3 -0.1483135 [8,] 3 -0.2362459 [9,] 3 0.3755072 [10,] 1 -1.4042598 [11,] 1 1.0330866 [12,] 1 -1.1282957 [13,] 2 -0.1655074 [14,] 2 0.1725528 [15,] 2 0.6400153 [16,] 1 1.7444893 attr(,"class") [1] "XY" "POLYGON" "sfg" attr(,"n_empty") [1] 0 attr(,"crs") $input [1] NA $wkt [1] NA attr(,"class") [1] "crs" attr(,"class") [1] "sfc_POLYGON" "sfc" attr(,"precision") [1] 0 attr(,"bbox") xmin ymin xmax ymax 1.000000 -1.404260 3.000000 2.550858 attr(,"class") [1] "bbox"
sfc_polygon( obj = df, x = 2, y = 3, z = 4)
[[1]] [[1]] [,1] [,2] [,3] [1,] 1 1.7444893 0.4826674 [2,] 1 2.5508583 -1.0474812 [3,] 1 -0.7329064 0.2879019 [4,] 2 0.7389258 -0.6532391 [5,] 2 1.8459791 -0.1153225 [6,] 2 0.5551210 -0.4613806 [7,] 3 -0.1483135 1.4460091 [8,] 3 -0.2362459 1.2497721 [9,] 3 0.3755072 0.1414420 [10,] 1 -1.4042598 -1.5065652 [11,] 1 1.0330866 1.0734309 [12,] 1 -1.1282957 0.3948881 [13,] 2 -0.1655074 -3.6519185 [14,] 2 0.1725528 0.5483315 [15,] 2 0.6400153 -0.1047943 [16,] 1 1.7444893 0.4826674 attr(,"class") [1] "XYZ" "POLYGON" "sfg" attr(,"n_empty") [1] 0 attr(,"crs") $input [1] NA $wkt [1] NA attr(,"class") [1] "crs" attr(,"class") [1] "sfc_POLYGON" "sfc" attr(,"precision") [1] 0 attr(,"bbox") xmin ymin xmax ymax 1.000000 -1.404260 3.000000 2.550858 attr(,"class") [1] "bbox" attr(,"z_range") zmin zmax -3.651918 1.446009 attr(,"class") [1] "z_range"
sfc_polygon( obj = df, x = 2, y = 3, z = 4, m = 5)
[[1]] [[1]] [,1] [,2] [,3] [,4] [1,] 1 1.7444893 0.4826674 -0.37887602 [2,] 1 2.5508583 -1.0474812 -0.67905602 [3,] 1 -0.7329064 0.2879019 -1.63413260 [4,] 2 0.7389258 -0.6532391 0.46286628 [5,] 2 1.8459791 -0.1153225 0.41299686 [6,] 2 0.5551210 -0.4613806 0.72507844 [7,] 3 -0.1483135 1.4460091 0.71304228 [8,] 3 -0.2362459 1.2497721 -0.19217631 [9,] 3 0.3755072 0.1414420 0.62974467 [10,] 1 -1.4042598 -1.5065652 -1.31013409 [11,] 1 1.0330866 1.0734309 -0.42148644 [12,] 1 -1.1282957 0.3948881 -0.09475231 [13,] 2 -0.1655074 -3.6519185 0.52279297 [14,] 2 0.1725528 0.5483315 -3.05068074 [15,] 2 0.6400153 -0.1047943 -0.20019534 [16,] 1 1.7444893 0.4826674 -0.37887602 attr(,"class") [1] "XYZM" "POLYGON" "sfg" attr(,"n_empty") [1] 0 attr(,"crs") $input [1] NA $wkt [1] NA attr(,"class") [1] "crs" attr(,"class") [1] "sfc_POLYGON" "sfc" attr(,"precision") [1] 0 attr(,"bbox") xmin ymin xmax ymax 1.000000 -1.404260 3.000000 2.550858 attr(,"class") [1] "bbox" attr(,"z_range") zmin zmax -3.651918 1.446009 attr(,"class") [1] "z_range" attr(,"m_range") mmin mmax -3.0506807 0.7250784 attr(,"class") [1] "m_range"
sfc_polygon( obj = df, polygon_id = "ml_id", linestring_id = "l_id" )
[[1]] [[1]] [,1] [,2] [,3] [,4] [1,] 1.7444893 0.4826674 -0.378876 0.7730972 [2,] 2.5508583 -1.0474812 -0.679056 0.6451763 [3,] -0.7329064 0.2879019 -1.634133 0.0716054 [4,] 1.7444893 0.4826674 -0.378876 0.7730972 [[2]] [,1] [,2] [,3] [,4] [1,] 0.7389258 -0.6532391 0.4628663 -1.63020333 [2,] 1.8459791 -0.1153225 0.4129969 0.04752034 [3,] 0.5551210 -0.4613806 0.7250784 -0.33390857 [4,] 0.7389258 -0.6532391 0.4628663 -1.63020333 [[3]] [,1] [,2] [,3] [,4] [1,] -0.1483135 1.446009 0.7130423 0.0829671 [2,] -0.2362459 1.249772 -0.1921763 -0.9527122 [3,] 0.3755072 0.141442 0.6297447 -0.9064257 [4,] -0.1483135 1.446009 0.7130423 0.0829671 attr(,"class") [1] "XYZM" "POLYGON" "sfg" [[2]] [[1]] [,1] [,2] [,3] [,4] [1,] -1.404260 -1.5065652 -1.31013409 0.574923 [2,] 1.033087 1.0734309 -0.42148644 -1.052674 [3,] -1.128296 0.3948881 -0.09475231 0.785319 [4,] -1.404260 -1.5065652 -1.31013409 0.574923 [[2]] [,1] [,2] [,3] [,4] [1,] -0.1655074 -3.6519185 0.5227930 -1.2717022 [2,] 0.1725528 0.5483315 -3.0506807 -0.2220049 [3,] 0.6400153 -0.1047943 -0.2001953 1.1486956 [4,] -0.1655074 -3.6519185 0.5227930 -1.2717022 attr(,"class") [1] "XYZM" "POLYGON" "sfg" attr(,"n_empty") [1] 0 attr(,"crs") $input [1] NA $wkt [1] NA attr(,"class") [1] "crs" attr(,"class") [1] "sfc_POLYGON" "sfc" attr(,"precision") [1] 0 attr(,"bbox") xmin ymin xmax ymax -1.404260 -3.651918 2.550858 1.446009 attr(,"class") [1] "bbox" attr(,"z_range") zmin zmax -3.0506807 0.7250784 attr(,"class") [1] "z_range" attr(,"m_range") mmin mmax -1.630203 1.148696 attr(,"class") [1] "m_range"
sfc_polygon( obj = df, polygon_id = 1, linestring_id = 2 )
[[1]] [[1]] [,1] [,2] [,3] [,4] [1,] 1.7444893 0.4826674 -0.378876 0.7730972 [2,] 2.5508583 -1.0474812 -0.679056 0.6451763 [3,] -0.7329064 0.2879019 -1.634133 0.0716054 [4,] 1.7444893 0.4826674 -0.378876 0.7730972 [[2]] [,1] [,2] [,3] [,4] [1,] 0.7389258 -0.6532391 0.4628663 -1.63020333 [2,] 1.8459791 -0.1153225 0.4129969 0.04752034 [3,] 0.5551210 -0.4613806 0.7250784 -0.33390857 [4,] 0.7389258 -0.6532391 0.4628663 -1.63020333 [[3]] [,1] [,2] [,3] [,4] [1,] -0.1483135 1.446009 0.7130423 0.0829671 [2,] -0.2362459 1.249772 -0.1921763 -0.9527122 [3,] 0.3755072 0.141442 0.6297447 -0.9064257 [4,] -0.1483135 1.446009 0.7130423 0.0829671 attr(,"class") [1] "XYZM" "POLYGON" "sfg" [[2]] [[1]] [,1] [,2] [,3] [,4] [1,] -1.404260 -1.5065652 -1.31013409 0.574923 [2,] 1.033087 1.0734309 -0.42148644 -1.052674 [3,] -1.128296 0.3948881 -0.09475231 0.785319 [4,] -1.404260 -1.5065652 -1.31013409 0.574923 [[2]] [,1] [,2] [,3] [,4] [1,] -0.1655074 -3.6519185 0.5227930 -1.2717022 [2,] 0.1725528 0.5483315 -3.0506807 -0.2220049 [3,] 0.6400153 -0.1047943 -0.2001953 1.1486956 [4,] -0.1655074 -3.6519185 0.5227930 -1.2717022 attr(,"class") [1] "XYZM" "POLYGON" "sfg" attr(,"n_empty") [1] 0 attr(,"crs") $input [1] NA $wkt [1] NA attr(,"class") [1] "crs" attr(,"class") [1] "sfc_POLYGON" "sfc" attr(,"precision") [1] 0 attr(,"bbox") xmin ymin xmax ymax -1.404260 -3.651918 2.550858 1.446009 attr(,"class") [1] "bbox" attr(,"z_range") zmin zmax -3.0506807 0.7250784 attr(,"class") [1] "z_range" attr(,"m_range") mmin mmax -1.630203 1.148696 attr(,"class") [1] "m_range"