1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288
|
R version 4.0.0 (2020-04-24) -- "Arbor Day"
Copyright (C) 2020 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> suppressPackageStartupMessages(library(sf))
>
> # create empty geometries:
> st_point(rep(NA_real_,2))
POINT EMPTY
> st_point(rep(NA_real_,3), dim = "XYZ")
POINT Z EMPTY
> st_point(rep(NA_real_,3), dim = "XYM")
POINT M EMPTY
> st_point(rep(NA_real_,4), dim = "XYZM")
POINT ZM EMPTY
>
> st_multipoint()
MULTIPOINT EMPTY
> st_multipoint(matrix(numeric(0), 0, 3), dim = "XYZ")
MULTIPOINT Z EMPTY
> st_multipoint(matrix(numeric(0), 0, 3), dim = "XYM")
MULTIPOINT M EMPTY
> st_multipoint(matrix(numeric(0), 0, 4), dim = "XYZM")
MULTIPOINT ZM EMPTY
>
> st_linestring(matrix(numeric(0), 0, 2), "XY")
LINESTRING EMPTY
> st_linestring(matrix(numeric(0), 0, 3), "XYZ")
LINESTRING Z EMPTY
> st_linestring(matrix(numeric(0), 0, 3), "XYM")
LINESTRING M EMPTY
> st_linestring(matrix(numeric(0), 0, 4), "XYZM")
LINESTRING ZM EMPTY
>
> st_multilinestring(list(), "XY")
MULTILINESTRING EMPTY
> st_multilinestring(list(), "XYZ")
MULTILINESTRING Z EMPTY
> st_multilinestring(list(), "XYM")
MULTILINESTRING M EMPTY
> st_multilinestring(list(), "XYZM")
MULTILINESTRING ZM EMPTY
>
> st_polygon(list(), "XY")
POLYGON EMPTY
> st_polygon(list(), "XYZ")
POLYGON Z EMPTY
> st_polygon(list(), "XYM")
POLYGON M EMPTY
> st_polygon(list(), "XYZM")
POLYGON ZM EMPTY
>
> st_multipolygon(list(), "XY")
MULTIPOLYGON EMPTY
> st_multipolygon(list(), "XYZ")
MULTIPOLYGON Z EMPTY
> st_multipolygon(list(), "XYM")
MULTIPOLYGON M EMPTY
> st_multipolygon(list(), "XYZM")
MULTIPOLYGON ZM EMPTY
>
> st_geometrycollection()
GEOMETRYCOLLECTION EMPTY
> st_geometrycollection(dim = "XYZ")
GEOMETRYCOLLECTION Z EMPTY
> st_geometrycollection(dim = "XYM")
GEOMETRYCOLLECTION M EMPTY
> st_geometrycollection(dim = "XYZM")
GEOMETRYCOLLECTION ZM EMPTY
>
> st_point(rep(NA_real_,2))
POINT EMPTY
> st_multipoint()
MULTIPOINT EMPTY
> st_linestring(matrix(numeric(0), 0, 2))
LINESTRING EMPTY
> st_multilinestring(list(), "XY")
MULTILINESTRING EMPTY
> st_polygon(list(), "XY")
POLYGON EMPTY
> st_multipolygon(list(), "XY")
MULTIPOLYGON EMPTY
> st_geometrycollection(, "XY")
GEOMETRYCOLLECTION EMPTY
>
> (e1 = st_sfc(
+ st_point(rep(NA_real_,2)),
+ st_multipoint(),
+ st_linestring(matrix(numeric(0), 0, 2)),
+ st_multilinestring(list(), "XY"),
+ st_polygon(list(), "XY"),
+ st_multipolygon(list(), "XY"),
+ st_geometrycollection(, "XY")))
Geometry set for 7 features (with 7 geometries empty)
geometry type: GEOMETRY
dimension: XY
bbox: xmin: NA ymin: NA xmax: NA ymax: NA
CRS: NA
First 5 geometries:
POINT EMPTY
MULTIPOINT EMPTY
LINESTRING EMPTY
MULTILINESTRING EMPTY
POLYGON EMPTY
>
> (e2 = st_sfc(st_point(rep(NA_real_,3), "XYZ"),
+ st_multipoint(matrix(numeric(0),0,3), dim = "XYZ"),
+ st_linestring(matrix(numeric(0), 0, 3)),
+ st_multilinestring(list(), "XYZ"),
+ st_polygon(list(), "XYZ"),
+ st_multipolygon(list(), "XYZ"),
+ st_geometrycollection(dim = "XYZ")))
Geometry set for 7 features (with 7 geometries empty)
geometry type: GEOMETRY
dimension: XYZ
bbox: xmin: NA ymin: NA xmax: NA ymax: NA
z_range: zmin: NA zmax: NA
CRS: NA
First 5 geometries:
POINT Z EMPTY
MULTIPOINT Z EMPTY
LINESTRING Z EMPTY
MULTILINESTRING Z EMPTY
POLYGON Z EMPTY
>
> (e3 = st_sfc(st_point(rep(NA_real_,3), "XYM"),
+ st_multipoint(matrix(numeric(0),0,3), dim = "XYM"),
+ st_linestring(matrix(numeric(0), 0, 3), "XYM"),
+ st_multilinestring(list(), "XYM"),
+ st_polygon(list(), "XYM"),
+ st_multipolygon(list(), "XYM"),
+ st_geometrycollection(dim = "XYM")))
Geometry set for 7 features (with 7 geometries empty)
geometry type: GEOMETRY
dimension: XYM
bbox: xmin: NA ymin: NA xmax: NA ymax: NA
m_range: mmin: NA mmax: NA
CRS: NA
First 5 geometries:
POINT M EMPTY
MULTIPOINT M EMPTY
LINESTRING M EMPTY
MULTILINESTRING M EMPTY
POLYGON M EMPTY
>
> (e4 = st_sfc(st_point(rep(NA_real_,4)),
+ st_multipoint(matrix(numeric(0),0,4), dim = "XYZM"),
+ st_linestring(matrix(numeric(0), 0, 4)),
+ st_multilinestring(list(), "XYZM"),
+ st_polygon(list(), "XYZM"),
+ st_multipolygon(list(), "XYZM"),
+ st_geometrycollection(dim = "XYZM")))
Geometry set for 7 features (with 7 geometries empty)
geometry type: GEOMETRY
dimension: XYZM
bbox: xmin: NA ymin: NA xmax: NA ymax: NA
z_range: zmin: NA zmax: NA
m_range: mmin: NA mmax: NA
CRS: NA
First 5 geometries:
POINT ZM EMPTY
MULTIPOINT ZM EMPTY
LINESTRING ZM EMPTY
MULTILINESTRING ZM EMPTY
POLYGON ZM EMPTY
>
> st_as_sfc(st_as_binary(e1, pureR = TRUE))
Geometry set for 7 features (with 7 geometries empty)
geometry type: GEOMETRY
dimension: XY
bbox: xmin: NA ymin: NA xmax: NA ymax: NA
CRS: NA
First 5 geometries:
POINT EMPTY
MULTIPOINT EMPTY
LINESTRING EMPTY
MULTILINESTRING EMPTY
POLYGON EMPTY
> st_as_sfc(st_as_binary(e1, pureR = FALSE))
Geometry set for 7 features (with 7 geometries empty)
geometry type: GEOMETRY
dimension: XY
bbox: xmin: NA ymin: NA xmax: NA ymax: NA
CRS: NA
First 5 geometries:
POINT EMPTY
MULTIPOINT EMPTY
LINESTRING EMPTY
MULTILINESTRING EMPTY
POLYGON EMPTY
> st_as_sfc(st_as_binary(e2, pureR = FALSE))
Geometry set for 7 features (with 7 geometries empty)
geometry type: GEOMETRY
dimension: XYZ
bbox: xmin: NA ymin: NA xmax: NA ymax: NA
z_range: zmin: NA zmax: NA
CRS: NA
First 5 geometries:
POINT Z EMPTY
MULTIPOINT Z EMPTY
LINESTRING Z EMPTY
MULTILINESTRING Z EMPTY
POLYGON Z EMPTY
> st_as_sfc(st_as_binary(e3, pureR = FALSE))
Geometry set for 7 features (with 7 geometries empty)
geometry type: GEOMETRY
dimension: XYM
bbox: xmin: NA ymin: NA xmax: NA ymax: NA
m_range: mmin: NA mmax: NA
CRS: NA
First 5 geometries:
POINT M EMPTY
MULTIPOINT M EMPTY
LINESTRING M EMPTY
MULTILINESTRING M EMPTY
POLYGON M EMPTY
> st_as_sfc(st_as_binary(e4, pureR = FALSE))
Geometry set for 7 features (with 7 geometries empty)
geometry type: GEOMETRY
dimension: XYZM
bbox: xmin: NA ymin: NA xmax: NA ymax: NA
z_range: zmin: NA zmax: NA
m_range: mmin: NA mmax: NA
CRS: NA
First 5 geometries:
POINT ZM EMPTY
MULTIPOINT ZM EMPTY
LINESTRING ZM EMPTY
MULTILINESTRING ZM EMPTY
POLYGON ZM EMPTY
> st_as_sfc(st_as_binary(e1, pureR = FALSE))
Geometry set for 7 features (with 7 geometries empty)
geometry type: GEOMETRY
dimension: XY
bbox: xmin: NA ymin: NA xmax: NA ymax: NA
CRS: NA
First 5 geometries:
POINT EMPTY
MULTIPOINT EMPTY
LINESTRING EMPTY
MULTILINESTRING EMPTY
POLYGON EMPTY
>
> # sfc_GEOMETRY:
> x = st_sfc(st_point(0:1), st_linestring(matrix(1:4,2,2)))
> st_intersects(x, x, sparse = FALSE)
[,1] [,2]
[1,] TRUE FALSE
[2,] FALSE TRUE
>
> # two empty geoms:
> x = st_sfc(st_multipoint(), st_linestring())
> st_intersects(x, x, sparse = FALSE)
[,1] [,2]
[1,] FALSE FALSE
[2,] FALSE FALSE
>
> # write & read:
> x = st_sf(a = 2:1, geom = structure(st_sfc(st_linestring(), st_linestring(matrix(1:4,2)))))
> write_sf(x, "empty.gpkg")
> y = st_read("empty.gpkg", quiet = TRUE)
> all.equal(x, y)
[1] TRUE
>
> # https://github.com/edzer/sfr/issues/398 :
> pt = st_sfc(st_point(c(0,92)), crs = 4267)
> robin_crs <- "+proj=robin +lon_0=0 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m +no_defs"
> # india_crs <- "+init=epsg:24383" # India-centered Lambert conformal conic projection
> india_crs <- "+proj=lcc +lat_1=12 +lat_0=12 +lon_0=80 +k_0=0.99878641 +x_0=2743195.5 +y_0=914398.5 +a=6377299.151 +b=6356098.145120132 +towgs84=295,736,257,0,0,0,0 +units=m +no_defs"
> st_transform(st_transform(pt, robin_crs), india_crs)[[1]]
POINT EMPTY
>
> proc.time()
user system elapsed
0.775 0.064 0.837
|