ropensci / osmextract

Download and import OpenStreetMap data from Geofabrik and other providers
https://docs.ropensci.org/osmextract
GNU General Public License v3.0
170 stars 12 forks source link

Add read poly #278

Closed agila5 closed 1 year ago

agila5 commented 1 year ago

Showcase the example:

library(osmextract)
#> Data (c) OpenStreetMap contributors, ODbL 1.0. https://www.openstreetmap.org/copyright.
#> Check the package website, https://docs.ropensci.org/osmextract/, for more details.
toy_poly <- c(
  "test_poly",
  "first_area",
  "0 0",
  "0 1",
  "1 1",
  "1 0",
  "0 0",
  "END",
  "END"
)
(out <- read_poly(toy_poly))
#> Geometry set for 1 feature 
#> Geometry type: MULTIPOLYGON
#> Dimension:     XY
#> Bounding box:  xmin: 0 ymin: 0 xmax: 1 ymax: 1
#> Geodetic CRS:  WGS 84
#> MULTIPOLYGON (((0 0, 0 1, 1 1, 1 0, 0 0)))
plot(out)

italy_poly <- "https://download.geofabrik.de/europe/italy.poly"
plot(read_poly(italy_poly))

Created on 2023-03-08 with reprex v2.0.2

Robinlovelace commented 1 year ago

Great work Andrea, clearly works, and useful for sure!