[This article was first published on Omnia sunt Communia! » R-english, 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.
The function slopeAspect
from raster
provides the vector field (gradient) from a scalar field stored in a RasterLayer
object. The magnitude (slope) and direction (aspect) of the vector field is usually displayed with a set of arrows (e.g. quiver
in Matlab). rasterVis
includes now a method, vectorplot
, to calculate and display this vector field
df <- expand.grid(x=seq(-2, 2, .1), y=seq(-2, 2, .1)) df$z <- with(df, (3*x^2 + y)*exp(-x^2-y^2)) r <- rasterFromXYZ(df) projection(r) <- CRS("+proj=longlat +datum=WGS84")vectorplot(r, par.settings=RdBuTheme)
To leave a comment for the author, please follow the link and comment on their blog: Omnia sunt Communia! » R-english.
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.