Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
I'm trying to migrate my tilegramsR package from sp to sf.
Here's how it works in the old
library(sp) evs <- tilegramsR::Pitch_US_Population_2016_v1 class(evs) plot(evs) # Each polygon is an electoral vote # Merge electoralvote polygons to state polygons using rmapshaper evs_states <- rmapshaper::ms_dissolve(evs, 'state') plot(evs_states) # Each polygon is a state
I converted the
sf_evs <- st_as_sf(evs) plot(sf_evs['state']) sf_evs_states <- dplyr::group_by(sf_evs, state) %>% dplyr::summarise(geometry = st_union(geometry)) %>% dplyr::ungroup() plot(sf_evs_states['state'])
Full code is uploaded at Rpubs