[This article was first published on R-NOLD, 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.
Talking about elevation, one can also plot a wire frame 3D view of an area using the persp function. Using the same data source from my previous post, 3D view of Marinduque, Philippines was produced using the following code below:Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
#############################################################################################
library(maptools)
library(raster)
alt <- getData(‘alt’, country=’PHL’)
adm <- getData(‘GADM’, country=’PHL’, leve=1)
mar<-(adm[adm$NAME_1==”Marinduque”,])
maralt<-crop(alt,mar)
persp(maralt, exp=0.2,phi=35, xlab=”Longitude”, ylab=”Latitude”, zlab=”Elevation”)
#############################################################################################
persp(maralt, exp=0.2,phi=35, xlab=”Longitude”, ylab=”Latitude”, zlab=”Elevation”, shade=0.45, col=”green4″)
#############################################################################################
To leave a comment for the author, please follow the link and comment on their blog: R-NOLD.
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.