Skip to content

Instantly share code, notes, and snippets.

@fawda123
Last active May 20, 2018 03:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fawda123/9315d9d975874e14340daccc0cd80274 to your computer and use it in GitHub Desktop.
Save fawda123/9315d9d975874e14340daccc0cd80274 to your computer and use it in GitHub Desktop.
chloroex
# load libraries
library(sf)
library(maps)
library(ggplot2)
# get states as sf
states <- st_as_sf(map('state', plot = F, fill = T))
# calculate area, add to states
area <- st_area(states)
area <- as.numeric(area) / 1e6
states$area <- area
# map
ggplot() +
geom_sf(data = states, aes(fill = area)) +
scale_fill_distiller(palette = 'Spectral')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment