Loading…
useR!2017 has ended
Back To Schedule
Thursday, July 6 • 5:55pm - 6:00pm
map data from **naturalearth** : aiming for sustainability through specialisation and **rOpenSci**

Sign up or log in to save this to your schedule, view media, leave feedback and see who's attending!

Feedback form is now closed.
Keywords: maps, package, sustainability, community
Webpages: https://CRAN.R-project.org/package=rnaturalearth, https://github.com/ropenscilabs/rnaturalearth
rnaturalearth is a new R package, accepted to CRAN in March this year. It makes Natural Earth map data, a free and open resource, more easily accessible to R users. It aims for a simple, reproducible and sustainable workflow from Natural Earth to rnaturalearth enabling updating as new versions become available.
rnaturalearth follows from rworldmap, a CRAN package for mapping world data, which I released more than 7 years ago. rworldmap was targetted particularly at relative newcomers to R, and has now been downloaded more than 100 thousand times. However, the code is ugly and I haven’t had the time to maintain it actively. I have been concerned for a while that making any changes will break it. Now more recently released options such as tmap and choroplethr are better than rworldmap in most respects.
Where rworldmap tried to do everything, rnaturalearth aims to do fewer things, but to do them better. This approach my be familiar to people. Also being more specialised allows this pacakage to be used in combination with other packages of the users choice.
It is possible to use rnaturalearth to have more control over accessing map data, for example specifiying exactly which areas are wanted when dealing with trickiness of countries and dependencies. In this example I use sp::plot as a simple, quick way to plot map data, however the output can also be returned as sf objects for plotting using other packages.
library(rnaturalearth) library(sp) # countries, UK undivided sp::plot(ne_countries(country = 'united kingdom', type = 'countries')) # map_units, UK divided into England, Scotland, Wales and Northern Ireland sp::plot(ne_countries(country = 'united kingdom', type = 'map_units')) # map_units, select by geounit to plot Scotland alone sp::plot(ne_countries(geounit = 'scotland', type = 'map_units')) # sovereignty, Falkland Islands included in UK sp::plot(ne_countries(country = 'united kingdom', type = 'sovereignty'), col = 'red') The package contains pre-downloaded country and state boundaries at different resolutions and facilitates access to other vector and raster data for example of lakes, rivers and roads. Each Natural Earth dataset is characterised on the website according to scale, type and category. rnaturalearth will construct the url and download the corresponding file.
lakes110 <- ne_download(scale = 110, type = 'lakes', category = 'physical') sp::plot(lakes110, col = 'blue') I found the early stages of rworldmap development a somewhat lonely process. rnaturalearth has been through the rOpenSci community open review which improved the code considerably and my experience of developing it. I look forward to this package being more collaborative. I will comment on my experience of issues of community and sustainability within R package development.

Speakers


Thursday July 6, 2017 5:55pm - 6:00pm CEST
2.01 Wild Gallery