


# CREATE DSM MAPS # import DSM data DSM_SJER <- raster ( "data/NEON-DS-Airborne-Remote-Sensing/SJER/DSM/SJER_dsmCrop.tif" ) # convert to a df for plotting DSM_SJER_df <- as.ame ( DSM_SJER, xy = TRUE ) # import DSM hillshade DSM_hill_SJER <- raster ( "data/NEON-DS-Airborne-Remote-Sensing/SJER/DSM/SJER_dsmHill.tif" ) # convert to a df for plotting DSM_hill_SJER_df <- as.ame ( DSM_hill_SJER, xy = TRUE ) # Build Plot ggplot () + geom_raster ( data = DSM_SJER_df, aes ( x = x, y = y, fill = SJER_dsmCrop, alpha = 0.8 ) ) + geom_raster ( data = DSM_hill_SJER_df, aes ( x = x, y = y, alpha = SJER_dsmHill ) ) + scale_fill_viridis_c () + guides ( fill = guide_colorbar ()) + scale_alpha ( range = c ( 0.4, 0.7 ), guide = "none" ) + # remove grey background and grid lines theme_bw () + theme ( = element_blank (), = element_blank ()) + xlab ( "UTM Easting Coordinate (m)" ) + ylab ( "UTM Northing Coordinate (m)" ) + ggtitle ( "DSM with Hillshade" ) + coord_quickmap () To begin with, we will use dplyr’s mutate() function combined with cut() to split the data into 3 bins. To make these decisions, it is useful to first explore the distribution of the data using a bar plot. To do this, we need to tell ggplot how many groups to break our data into, and ForĬlarity and visibility of the plot, we may prefer to view the data “symbolized” or colored according to ranges of values. In the previous episode, we viewed our data using a continuous color ramp. We will continue working with the Digital Surface Model (DSM) rasterįor the NEON Harvard Forest Field Site. It also covers how to layer a raster on top of a hillshade to produceĪn eloquent map. Package with customized coloring schemes. This episode covers how to plot a raster in R using the ggplot2 See the lesson homepage for detailed information about the software,ĭata, and other prerequisites you will need to work through the examples in this episode. Things You’ll Need To Complete This Episode Layer a raster dataset on top of a hillshade to create an elegant basemap.

Build customized plots for a single band raster using the ggplot2 package.
