ropensci / rnaturalearth

An R package to hold and facilitate interaction with natural earth map data :earth_africa:
http://ropensci.github.io/rnaturalearth/
Other
214 stars 24 forks source link

Download data for parks and protected lands? #39

Closed jrosen48 closed 4 weeks ago

jrosen48 commented 3 years ago

Thanks for creating an incredible package! Is it possible to download data for parks and protected lands?

It is not listed as available in the README(below the heading "To download Natural Earth data not already in the package"), but is listed on the Natural Earth website:

https://www.naturalearthdata.com/downloads/10m-cultural-vectors/

andysouth commented 3 years ago

Thanks @jrosen48

It is possible to download most layers from natural earth using ne_download() but I hadn't noticed before that it doesn't work for the parks layers. This is because there are separate layers for area, line and point within the zip stored in the Natural Earth website.

This means that the code I expected to work (below), does download the data but then fails to load it.

Afraid I'm not quite sure how to solve that yet.

sfparks <- ne_download(scale=10, type="parks_and_protected_lands", returnclass = 'sf') trying URL 'http://www.naturalearthdata.com/http//www.naturalearthdata.com/download/10m/cultural/ne_10m_parks_and_protected_lands.zip' Content type 'application/zip' length 164198 bytes (160 KB) downloaded 160 KB

Error in ogrInfo(dsn = dsn, layer = layer, encoding = encoding, use_iconv = use_iconv, : Cannot open layer

PMassicotte commented 1 year ago

One could use:

st_read("/vsizip//ne_10m_parks_and_protected_lands.zip", layer = "ne_10m_parks_and_protected_lands_area")

Layers can be listed with:

sf::st_layers("/vsizip//ne_10m_parks_and_protected_lands.zip")
PMassicotte commented 4 weeks ago
st_read("/vsizip/vsicurl/https://naciscdn.org/naturalearth/10m/cultural/ne_10m_parks_and_protected_lands.zip")