#Know how to plot a single band raster in R.
#Know how to layer a raster dataset on top of a hillshade to create an elegant basemap
library(pacman)
p_load(raster, rgdal)
wd <- "G:/Rdata/neon_data/NEONDSAirborneRemoteSensing/"
setwd(wd)
DSM_HARV <- raster(paste0(wd,"HARV/DSM/HARV_dsmCrop.tif"))
#plot raster object
plot(DSM_HARV,
main = "Digital Surface Model\n NEON Harvard Forest Field Site")
#plot distribution of raster values
DSMhist <- hist(DSM_HARV,
breaks = 3,
main="Histogram Digital Surface Model\n NEON Harvard Forest Field Site",
col = "wheat3",
xlab = "Elevation(m)")
#where are breaks and how many pixels in each category
DSMhist$breaks
# [1] 300 350 400 450
DSMhist$counts
# [1] 32180 67382 438
#Plot using breaks
plot(DSM_HARV,
breaks = c(300,350,400,450),
col = terrain.colors(3),
main = "Digital Surface Model(DSM)\n NEON Harvrad Forest Field Site",
axes = F#不显示坐标轴
)
DSM_hill_HARV <- raster(paste0(wd,"HARV/DSM/HARV_DSMhill.tif"))
plot(DSM_hill_HARV,
col=grey(1:100/100),
legend=F,
main = "DSM with Hillshade\nNEON Harvard Forest Field Site",
axes = F)
plot(DSM_HARV,
col = rainbow(100),
alpha = 0.4,
add = T,
legend = F,
)