geometrycollection class

geometrycollection(x)

Arguments

x

input

Examples

x <- '{ "type": "GeometryCollection", "geometries": [ { "type": "Point", "coordinates": [100.0, 0.0] }, { "type": "LineString", "coordinates": [ [101.0, 0.0], [102.0, 1.0] ] } ] }' (y <- geometrycollection(x))
#> <GeometryCollection> #> geometries (n): 2 #> geometries (geometry / length): #> Point / 2 #> LineString / 2
#> [1] "GeometryCollection"
#> { #> "type": "GeometryCollection", #> "geometries": [ #> { #> "type": "Point", #> "coordinates": [ #> 100.0, #> 0.0 #> ] #> }, #> { #> "type": "LineString", #> "coordinates": [ #> [ #> 101.0, #> 0.0 #> ], #> [ #> 102.0, #> 1.0 #> ] #> ] #> } #> ] #> } #>
geo_write(y, f <- tempfile(fileext = ".geojson")) jsonlite::fromJSON(f, FALSE)
#> $type #> [1] "GeometryCollection" #> #> $geometries #> $geometries[[1]] #> $geometries[[1]]$type #> [1] "Point" #> #> $geometries[[1]]$coordinates #> $geometries[[1]]$coordinates[[1]] #> [1] 100 #> #> $geometries[[1]]$coordinates[[2]] #> [1] 0 #> #> #> #> $geometries[[2]] #> $geometries[[2]]$type #> [1] "LineString" #> #> $geometries[[2]]$coordinates #> $geometries[[2]]$coordinates[[1]] #> $geometries[[2]]$coordinates[[1]][[1]] #> [1] 101 #> #> $geometries[[2]]$coordinates[[1]][[2]] #> [1] 0 #> #> #> $geometries[[2]]$coordinates[[2]] #> $geometries[[2]]$coordinates[[2]][[1]] #> [1] 102 #> #> $geometries[[2]]$coordinates[[2]][[2]] #> [1] 1 #> #> #> #> #>
unlink(f) # bigger geometrycollection file <- system.file("examples", "geometrycollection1.geojson", package = "geojson") (y <- geometrycollection(paste0(readLines(file), collapse="")))
#> <GeometryCollection> #> geometries (n): 3 #> geometries (geometry / length): #> Point / 2 #> Polygon / 1 #> LineString / 36
#> [1] "GeometryCollection"
#> { #> "type": "GeometryCollection", #> "geometries": [ #> { #> "type": "Point", #> "coordinates": [ #> -80.66080570220947, #> 35.04939206472683 #> ] #> }, #> { #> "type": "Polygon", #> "coordinates": [ #> [ #> [ #> -80.66458225250244, #> 35.04496519190309 #> ], #> [ #> -80.66344499588013, #> 35.04603679820616 #> ], #> [ #> -80.66258668899536, #> 35.045580049697556 #> ], #> [ #> -80.66387414932251, #> 35.044280059194946 #> ], #> [ #> -80.66458225250244, #> 35.04496519190309 #> ] #> ] #> ] #> }, #> { #> "type": "LineString", #> "coordinates": [ #> [ #> -80.66237211227417, #> 35.05950973022538 #> ], #> [ #> -80.66269397735596, #> 35.0592638296087 #> ], #> [ #> -80.66284418106079, #> 35.05893010615862 #> ], #> [ #> -80.66308021545409, #> 35.05833291342246 #> ], #> [ #> -80.66359519958496, #> 35.057753281001425 #> ], #> [ #> -80.66387414932251, #> 35.05740198662245 #> ], #> [ #> -80.66441059112549, #> 35.05703312589789 #> ], #> [ #> -80.66486120223999, #> 35.056787217822475 #> ], #> [ #> -80.66541910171509, #> 35.05650617911516 #> ], #> [ #> -80.66563367843628, #> 35.05631296444281 #> ], #> [ #> -80.66601991653441, #> 35.055891403570705 #> ], #> [ #> -80.66619157791138, #> 35.05545227534804 #> ], #> [ #> -80.66619157791138, #> 35.05517123204622 #> ], #> [ #> -80.66625595092773, #> 35.05489018777713 #> ], #> [ #> -80.6662130355835, #> 35.054222703761525 #> ], #> [ #> -80.6662130355835, #> 35.05392409072499 #> ], #> [ #> -80.66595554351807, #> 35.05290528508858 #> ], #> [ #> -80.66569805145262, #> 35.052044560077285 #> ], #> [ #> -80.66550493240356, #> 35.0514824490509 #> ], #> [ #> -80.665762424469, #> 35.05048117920187 #> ], #> [ #> -80.66617012023926, #> 35.04972582715769 #> ], #> [ #> -80.66651344299316, #> 35.049286665781096 #> ], #> [ #> -80.66692113876343, #> 35.0485313026898 #> ], #> [ #> -80.66700696945189, #> 35.048215102112344 #> ], #> [ #> -80.66707134246826, #> 35.04777593261294 #> ], #> [ #> -80.66704988479614, #> 35.04738946150025 #> ], #> [ #> -80.66696405410767, #> 35.04698542156371 #> ], #> [ #> -80.66681385040283, #> 35.046353007216055 #> ], #> [ #> -80.66659927368164, #> 35.04596652937105 #> ], #> [ #> -80.66640615463257, #> 35.04561518428889 #> ], #> [ #> -80.6659984588623, #> 35.045193568195565 #> ], #> [ #> -80.66552639007568, #> 35.044877354697526 #> ], #> [ #> -80.6649899482727, #> 35.04454357245502 #> ], #> [ #> -80.66449642181396, #> 35.04417465365292 #> ], #> [ #> -80.66385269165039, #> 35.04387600387859 #> ], #> [ #> -80.66303730010986, #> 35.043717894732545 #> ] #> ] #> } #> ] #> } #>