Skip to content

Commit

Permalink
update url link to remove dc
Browse files Browse the repository at this point in the history
  • Loading branch information
bhass-neon committed Feb 17, 2024
1 parent f0e884c commit 678cef6
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 25 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
## ----load-libraries, results="hide"------------------------------------------------------------------------------------------------------------------------------------------------
## ----load-libraries, results="hide"----------------------------------------------------------------------------------------------------------------
library(terra)

# set working directory, you can change this if desired
wd <- "~/data/"
setwd(wd)


## ----download-dsm-data, eval=FALSE-------------------------------------------------------------------------------------------------------------------------------------------------
## ----download-dsm-data, eval=FALSE-----------------------------------------------------------------------------------------------------------------
## byTileAOP(dpID='DP3.30024.001', # lidar elevation
## site='HARV',
## year='2022',
Expand All @@ -16,7 +16,7 @@ setwd(wd)
## savepath = wd)


## ----open-raster, fig.cap="Digital surface model showing the elevation of NEON's site Harvard Forest"------------------------------------------------------------------------------
## ----open-raster, fig.cap="Digital surface model showing the elevation of NEON's site Harvard Forest"----------------------------------------------
# Load raster into R
dsm_harv_file <- paste0(wd, "DP3.30024.001/neon-aop-products/2022/FullSite/D01/2022_HARV_7/L3/DiscreteLidar/DSMGtif/NEON_D01_HARV_DP3_732000_4713000_DSM.tif")
DSM_HARV <- rast(dsm_harv_file)
Expand All @@ -29,7 +29,7 @@ plot(DSM_HARV, main="Digital Surface Model - HARV")



## ----classified-elevation-map, fig.cap="Classified elevation map of NEON's site Harvard Forest", fig.width=10----------------------------------------------------------------------
## ----classified-elevation-map, fig.cap="Classified elevation map of NEON's site Harvard Forest", fig.width=10--------------------------------------
# add a color map with 5 colors
col=terrain.colors(3)
# add breaks to the colormap (4 breaks = 3 segments)
Expand All @@ -53,7 +53,7 @@ legend( 733100, 4713700,
fill = rev(col))


## ----view-crs----------------------------------------------------------------------------------------------------------------------------------------------------------------------
## ----view-crs--------------------------------------------------------------------------------------------------------------------------------------
# view crs description
crs(DSM_HARV,describe=TRUE)

Expand All @@ -62,20 +62,20 @@ harvCRS <- crs(DSM_HARV)



## ----show-ext----------------------------------------------------------------------------------------------------------------------------------------------------------------------
## ----show-ext--------------------------------------------------------------------------------------------------------------------------------------
ext(DSM_HARV)


## ----resolution-units--------------------------------------------------------------------------------------------------------------------------------------------------------------
## ----resolution-units------------------------------------------------------------------------------------------------------------------------------
crs(DSM_HARV,proj=TRUE)


## ----view-min-max------------------------------------------------------------------------------------------------------------------------------------------------------------------
## ----view-min-max----------------------------------------------------------------------------------------------------------------------------------
# view the min and max values
min(DSM_HARV)


## ----download-rgb-data, eval=FALSE-------------------------------------------------------------------------------------------------------------------------------------------------
## ----download-rgb-data, eval=FALSE-----------------------------------------------------------------------------------------------------------------
## byTileAOP(dpID='DP3.30010.001',
## site='HARV',
## year='2022',
Expand All @@ -85,7 +85,7 @@ min(DSM_HARV)
## savepath = wd)


## ----demonstrate-no-data-black, fig.cap="Colorized raster image with NoDataValues around the edge rendered in black"---------------------------------------------------------------
## ----demonstrate-no-data-black, fig.cap="Colorized raster image with NoDataValues around the edge rendered in black"-------------------------------
# Use rast function to read in all bands
RGB_HARV <-
rast(paste0(wd,"DP3.30010.001/neon-aop-products/2022/FullSite/D01/2022_HARV_7/L3/Camera/Mosaic/2022_HARV_7_737000_4701000_image.tif"))
Expand All @@ -96,7 +96,7 @@ plotRGB(RGB_HARV, r = 1, g = 2, b = 3, axes=TRUE)



## ----demonstrate-no-data, fig.cap="Colorized raster image with NoDataValues around the edge removed"-------------------------------------------------------------------------------
## ----demonstrate-no-data, fig.cap="Colorized raster image with NoDataValues around the edge removed"-----------------------------------------------
# reassign cells with 0,0,0 to NA
func <- function(x) {
x[rowSums(x == 0) == 3, ] <- NA
Expand All @@ -110,7 +110,7 @@ plotRGB(newRGBImage, r = 1, g = 2, b = 3, axis=TRUE)



## ----view-raster-histogram, fig.cap="Histogram showing the distribution of digital surface model values"---------------------------------------------------------------------------
## ----view-raster-histogram, fig.cap="Histogram showing the distribution of digital surface model values"-------------------------------------------

# view histogram of data
hist(DSM_HARV,
Expand All @@ -121,34 +121,34 @@ hist(DSM_HARV,



## ----view-dsm-bands----------------------------------------------------------------------------------------------------------------------------------------------------------------
## ----view-dsm-bands--------------------------------------------------------------------------------------------------------------------------------

# view number of bands in the Lidar DSM raster
nlyr(DSM_HARV)


## ----view-rgb-bands----------------------------------------------------------------------------------------------------------------------------------------------------------------
## ----view-rgb-bands--------------------------------------------------------------------------------------------------------------------------------

# view number of bands in the RGB Camera raster
nlyr(RGB_HARV)



## ----describe-meta-----------------------------------------------------------------------------------------------------------------------------------------------------------------
## ----describe-meta---------------------------------------------------------------------------------------------------------------------------------

# view metadata attributes before opening the file
describe(path.expand(dsm_harv_file),meta=TRUE)



## ----describe-stats----------------------------------------------------------------------------------------------------------------------------------------------------------------
## ----describe-stats--------------------------------------------------------------------------------------------------------------------------------

# view summary statistics before opening the file
describe(path.expand(dsm_harv_file),options=c("stats"))



## ----challenge-code-attributes, eval=FALSE, echo=FALSE-----------------------------------------------------------------------------------------------------------------------------
## ----challenge-code-attributes, eval=FALSE, echo=FALSE---------------------------------------------------------------------------------------------
## dtm_harv_file <- paste0(wd, "DP3.30024.001/neon-aop-products/2022/FullSite/D01/2022_HARV_7/L3/DiscreteLidar/DTMGtif/NEON_D01_HARV_DP3_732000_4713000_DTM.tif")
## describe(path.expand(dtm_harv_file))
##
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## ----load-libraries----------------------------------------------------------------------------------------------------------------------------------------------------------------
## ----load-libraries--------------------------------------------------------------------------------------------------------------------------------
library(terra)

# set working directory
Expand All @@ -10,13 +10,13 @@ dsm_harv_file <- paste0(wd, "DP3.30024.001/neon-aop-products/2022/FullSite/D01/2
DSM_HARV <- rast(dsm_harv_file)


## ----hist-raster, fig.cap="Digital surface model showing the continuous elevation of NEON's site Harvard Forest"-------------------------------------------------------------------
## ----hist-raster, fig.cap="Digital surface model showing the continuous elevation of NEON's site Harvard Forest"-----------------------------------
# Plot raster object
plot(DSM_HARV, main="Digital Surface Model - HARV")



## ----create-histogram-breaks, fig.cap="Histogram of digital surface model showing the distribution of the elevation of NEON's site Harvard Forest"---------------------------------
## ----create-histogram-breaks, fig.cap="Histogram of digital surface model showing the distribution of the elevation of NEON's site Harvard Forest"----
# Plot distribution of raster values
DSMhist<-hist(DSM_HARV,
breaks=3,
Expand All @@ -30,7 +30,7 @@ DSMhist$counts



## ----plot-with-breaks, fig.cap="Digital surface model showing the elevation of NEON's site Harvard Forest with three breaks"-------------------------------------------------------
## ----plot-with-breaks, fig.cap="Digital surface model showing the elevation of NEON's site Harvard Forest with three breaks"-----------------------
# plot using breaks.
plot(DSM_HARV,
breaks = c(300, 350, 400, 450),
Expand All @@ -52,7 +52,7 @@ plot(DSM_HARV,
ylab = "UTM Northing (m)")


## ----turn-off-axes,fig.cap="Digital surface model showing the elevation of NEON's site Harvard Forest with no axes"----------------------------------------------------------------
## ----turn-off-axes,fig.cap="Digital surface model showing the elevation of NEON's site Harvard Forest with no axes"--------------------------------
# or we can turn off the axis altogether
plot(DSM_HARV,
breaks = c(300, 350, 400, 450),
Expand All @@ -62,7 +62,7 @@ plot(DSM_HARV,



## ----challenge-code-plotting, include=TRUE, results="hide", echo=FALSE-------------------------------------------------------------------------------------------------------------
## ----challenge-code-plotting, include=TRUE, results="hide", echo=FALSE-----------------------------------------------------------------------------
# Find min & max
min(DSM_HARV)

Expand All @@ -77,7 +77,7 @@ plot(DSM_HARV,



## ----slope-aspect-hill-------------------------------------------------------------------------------------------------------------------------------------------------------------
## ----slope-aspect-hill-----------------------------------------------------------------------------------------------------------------------------
slope <- terrain(DSM_HARV, "slope", unit="radians")
aspect <- terrain(DSM_HARV, "aspect", unit="radians")
hill <- shade(slope, aspect, 45, 270)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ languagesTool: R
dataProduct: DP3.30024.001
code1: https://raw.githubusercontent.com/NEONScience/NEON-Data-Skills/main/tutorials/R/Geospatial-skills/intro-raster-r/01-Plot-Raster/01-Plot-Raster.R
tutorialSeries: raster-data-series
urlTitle: dc-plot-raster-data-r
urlTitle: plot-raster-data-r
---


Expand Down

0 comments on commit 678cef6

Please sign in to comment.