Skip to content

Instantly share code, notes, and snippets.

@etiennebr
Created December 21, 2016 22:45
Show Gist options
  • Save etiennebr/568021a59b0077fedc85da5444c13db2 to your computer and use it in GitHub Desktop.
Save etiennebr/568021a59b0077fedc85da5444c13db2 to your computer and use it in GitHub Desktop.
sf in dplyr style
# dplyr style
polygons %>%
mutate(value = raster::extract.sfg(geometry, r, mean)) %>%
plot()
# sp style
value = raster::extract(polygons, r, mean, df = TRUE)
# multiple values
md <- function(x) data.frame(m = mean(x), d = sd(x)
polygons %>%
mutatem(value = raster::extract.sfg(geometry, r, md)) %>%
plot()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment