Closed benyamindsmith closed 1 year ago
You only need to add the return_class argument to specify that the function returns an object of type sf. This should work with any of the natural earth functions:
library(rnaturalearth)
library(ggplot2)
df <- ne_states(country = 'france', returnclass = 'sf')
ggplot(df) +
geom_sf()
Is it possible to use the data from
ne_states()
with ggplot2?From the documentation it seems like its only "out of the box computable" with base R's
plot()
function.I'm asking because
ne_countries()
seems to work pretty well and is pretty easy to read as far as output is concerned because its a tibble is outputted.ne_states()
returns a list which is hard to understand exactly what needs to be passed as arguments to work with ggplot.Thanks!