@@ -156,13 +156,13 @@ If you wish to store this information in R, you can do the following:
156156
157157
158158``` r
159- HARV_dsmCrop_info <- capture.output(
159+ harv_metadata <- capture.output(
160160 describe(" data/NEON-DS-Airborne-Remote-Sensing/HARV/DSM/HARV_dsmCrop.tif" )
161161)
162162```
163163
164164Each line of text that was printed to the console is now stored as an element of
165- the character vector ` HARV_dsmCrop_info ` . We will be exploring this data throughout this
165+ the character vector ` harv_metadata ` . We will be exploring this data throughout this
166166episode. By the end of this episode, you will be able to explain and understand the output above.
167167
168168## Open a Raster in R
@@ -187,10 +187,10 @@ First we will load our raster file into R and view the data structure.
187187
188188
189189``` r
190- DSM_HARV <-
190+ dsm_harv <-
191191 rast(" data/NEON-DS-Airborne-Remote-Sensing/HARV/DSM/HARV_dsmCrop.tif" )
192192
193- DSM_HARV
193+ dsm_harv
194194```
195195
196196``` output
@@ -211,7 +211,7 @@ columns, descriptive statistics for raster data can be retrieved like
211211
212212
213213``` r
214- summary(DSM_HARV )
214+ summary(dsm_harv )
215215```
216216
217217``` warning
@@ -235,7 +235,7 @@ the function `values`:
235235
236236
237237``` r
238- summary(values(DSM_HARV ))
238+ summary(values(dsm_harv ))
239239```
240240
241241``` output
@@ -255,15 +255,15 @@ The `terra` package has an built-in function for conversion to a plotable datafr
255255
256256
257257``` r
258- DSM_HARV_df <- as.data.frame(DSM_HARV , xy = TRUE )
258+ dsm_harv_df <- as.data.frame(dsm_harv , xy = TRUE )
259259```
260260
261261Now when we view the structure of our data, we will see a standard
262262dataframe format.
263263
264264
265265``` r
266- str(DSM_HARV_df )
266+ str(dsm_harv_df )
267267```
268268
269269``` output
@@ -283,7 +283,7 @@ ggplot2 if needed, you can learn about them at their help page `?coord_map`.
283283
284284``` r
285285ggplot() +
286- geom_raster(data = DSM_HARV_df , aes(x = x , y = y , fill = HARV_dsmCrop )) +
286+ geom_raster(data = dsm_harv_df , aes(x = x , y = y , fill = HARV_dsmCrop )) +
287287 scale_fill_viridis_c() +
288288 coord_quickmap()
289289```
@@ -318,7 +318,7 @@ See `?plot` for more arguments to customize the plot
318318
319319
320320``` r
321- plot(DSM_HARV )
321+ plot(dsm_harv )
322322```
323323
324324<img src =" fig/01-raster-structure-rendered-unnamed-chunk-7-1.png " style =" display : block ; margin : auto ;" />
@@ -352,7 +352,7 @@ function.
352352
353353
354354``` r
355- crs(DSM_HARV , proj = TRUE )
355+ crs(dsm_harv , proj = TRUE )
356356```
357357
358358``` output
@@ -386,7 +386,7 @@ and datum (`datum=`).
386386
387387### UTM Proj4 String
388388
389- A projection string (like the one of ` DSM_HARV ` ) specifies the UTM projection
389+ A projection string (like the one of ` dsm_harv ` ) specifies the UTM projection
390390as follows:
391391
392392` +proj=utm +zone=18 +datum=WGS84 +units=m +no_defs +ellps=WGS84 +towgs84=0,0,0 `
@@ -416,7 +416,7 @@ can view these values:
416416
417417
418418``` r
419- minmax(DSM_HARV )
419+ minmax(dsm_harv )
420420```
421421
422422``` output
@@ -426,15 +426,15 @@ max 416.07
426426```
427427
428428``` r
429- min(values(DSM_HARV ))
429+ min(values(dsm_harv ))
430430```
431431
432432``` output
433433[1] 305.07
434434```
435435
436436``` r
437- max(values(DSM_HARV ))
437+ max(values(dsm_harv ))
438438```
439439
440440``` output
@@ -451,7 +451,7 @@ calculated, we can calculate them using the
451451
452452
453453``` r
454- DSM_HARV <- setMinMax(DSM_HARV )
454+ dsm_harv <- setMinMax(dsm_harv )
455455```
456456
457457::::::::::::::::::::::::::::::::::::::::::::::::::
@@ -461,7 +461,7 @@ We can see that the elevation at our site ranges from 305.0700073m to
461461
462462## Raster Bands
463463
464- The Digital Surface Model object (` DSM_HARV ` ) that we've been working with is a
464+ The Digital Surface Model object (` dsm_harv ` ) that we've been working with is a
465465single band raster. This means that there is only one dataset stored in the
466466raster: surface elevation in meters for one time period.
467467
@@ -473,7 +473,7 @@ view the number of bands in a raster using the `nlyr()` function.
473473
474474
475475``` r
476- nlyr(DSM_HARV )
476+ nlyr(dsm_harv )
477477```
478478
479479``` output
@@ -543,15 +543,15 @@ of `NA` will be ignored by R as demonstrated above.
543543## Challenge
544544
545545Use the output from the ` describe() ` and ` sources() ` functions to find out what
546- ` NoDataValue ` is used for our ` DSM_HARV ` dataset.
546+ ` NoDataValue ` is used for our ` dsm_harv ` dataset.
547547
548548::::::::::::::: solution
549549
550550## Answers
551551
552552
553553``` r
554- describe(sources(DSM_HARV ))
554+ describe(sources(dsm_harv ))
555555```
556556
557557``` output
@@ -665,7 +665,7 @@ useful in identifying outliers and bad data values in our raster data.
665665
666666``` r
667667ggplot() +
668- geom_histogram(data = DSM_HARV_df , aes(HARV_dsmCrop ))
668+ geom_histogram(data = dsm_harv_df , aes(HARV_dsmCrop ))
669669```
670670
671671``` output
@@ -685,7 +685,7 @@ by using the `bins` value in the `geom_histogram()` function.
685685
686686``` r
687687ggplot() +
688- geom_histogram(data = DSM_HARV_df , aes(HARV_dsmCrop ), bins = 40 )
688+ geom_histogram(data = dsm_harv_df , aes(HARV_dsmCrop ), bins = 40 )
689689```
690690
691691<img src =" fig/01-raster-structure-rendered-view-raster-histogram2-1.png " style =" display : block ; margin : auto ;" />
@@ -701,7 +701,7 @@ no bad data values in this particular raster.
701701
702702Use ` describe() ` to determine the following about the ` NEON-DS-Airborne-Remote-Sensing/HARV/DSM/HARV_DSMhill.tif ` file:
703703
704- 1 . Does this file have the same CRS as ` DSM_HARV ` ?
704+ 1 . Does this file have the same CRS as ` dsm_harv ` ?
7057052 . What is the ` NoDataValue ` ?
7067063 . What is resolution of the raster data?
7077074 . How large would a 5x5 pixel area be on the Earth's surface?
@@ -787,7 +787,7 @@ describe("data/NEON-DS-Airborne-Remote-Sensing/HARV/DSM/HARV_DSMhill.tif")
787787```
788788
789789
790- 1 . If this file has the same CRS as DSM_HARV ? Yes: UTM Zone 18, WGS84, meters.
790+ 1 . If this file has the same CRS as dsm_harv ? Yes: UTM Zone 18, WGS84, meters.
7917912 . What format ` NoDataValues ` take? -9999
7927923 . The resolution of the raster data? 1x1
7937934 . How large a 5x5 pixel area would be? 5mx5m How? We are given resolution of 1x1 and units in meters, therefore resolution of 5x5 means 5x5m.
0 commit comments