R GIS: Terrain Analysis for Polygons as Simple as it Gets!
[This article was first published on theBioBucket*, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
library(rgdal) library(raster) alt <- getData('alt', country = "AT") gadm <- getData('GADM', country = "AT", level = 2) gadm_sub <- gadm[sample(1:length(gadm), 5), ] plot(alt) plot(gadm_sub, add=T) asp <- terrain(alt, opt = "aspect", unit = "degrees", df = F) slo <- terrain(alt, opt = "slope", unit = "degrees", df = F) > extract(slo, gadm_sub, fun = mean, na.rm = T, small = T, df = T) ID slope 1 1 9.959053 2 2 1.047443 3 3 7.456165 4 4 1.673786 5 5 11.946553 > extract(asp, gadm_sub, fun = mean, na.rm = T, small = T, df = T) ID aspect 1 1 170.8065 2 2 184.0130 3 3 190.7155 4 4 136.8953 5 5 205.2115
To leave a comment for the author, please follow the link and comment on their blog: theBioBucket*.
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.