@@ -156,13 +156,13 @@ If you wish to store this information in R, you can do the following:
156
156
157
157
158
158
``` r
159
- HARV_dsmCrop_info <- capture.output(
159
+ harv_metadata <- capture.output(
160
160
describe(" data/NEON-DS-Airborne-Remote-Sensing/HARV/DSM/HARV_dsmCrop.tif" )
161
161
)
162
162
```
163
163
164
164
Each 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
166
166
episode. By the end of this episode, you will be able to explain and understand the output above.
167
167
168
168
## Open a Raster in R
@@ -187,10 +187,10 @@ First we will load our raster file into R and view the data structure.
187
187
188
188
189
189
``` r
190
- DSM_HARV <-
190
+ dsm_harv <-
191
191
rast(" data/NEON-DS-Airborne-Remote-Sensing/HARV/DSM/HARV_dsmCrop.tif" )
192
192
193
- DSM_HARV
193
+ dsm_harv
194
194
```
195
195
196
196
``` output
@@ -211,7 +211,7 @@ columns, descriptive statistics for raster data can be retrieved like
211
211
212
212
213
213
``` r
214
- summary(DSM_HARV )
214
+ summary(dsm_harv )
215
215
```
216
216
217
217
``` warning
@@ -235,7 +235,7 @@ the function `values`:
235
235
236
236
237
237
``` r
238
- summary(values(DSM_HARV ))
238
+ summary(values(dsm_harv ))
239
239
```
240
240
241
241
``` output
@@ -255,15 +255,15 @@ The `terra` package has an built-in function for conversion to a plotable datafr
255
255
256
256
257
257
``` r
258
- DSM_HARV_df <- as.data.frame(DSM_HARV , xy = TRUE )
258
+ dsm_harv_df <- as.data.frame(dsm_harv , xy = TRUE )
259
259
```
260
260
261
261
Now when we view the structure of our data, we will see a standard
262
262
dataframe format.
263
263
264
264
265
265
``` r
266
- str(DSM_HARV_df )
266
+ str(dsm_harv_df )
267
267
```
268
268
269
269
``` output
@@ -283,7 +283,7 @@ ggplot2 if needed, you can learn about them at their help page `?coord_map`.
283
283
284
284
``` r
285
285
ggplot() +
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 )) +
287
287
scale_fill_viridis_c() +
288
288
coord_quickmap()
289
289
```
@@ -318,7 +318,7 @@ See `?plot` for more arguments to customize the plot
318
318
319
319
320
320
``` r
321
- plot(DSM_HARV )
321
+ plot(dsm_harv )
322
322
```
323
323
324
324
<img src =" fig/01-raster-structure-rendered-unnamed-chunk-7-1.png " style =" display : block ; margin : auto ;" />
@@ -352,7 +352,7 @@ function.
352
352
353
353
354
354
``` r
355
- crs(DSM_HARV , proj = TRUE )
355
+ crs(dsm_harv , proj = TRUE )
356
356
```
357
357
358
358
``` output
@@ -386,7 +386,7 @@ and datum (`datum=`).
386
386
387
387
### UTM Proj4 String
388
388
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
390
390
as follows:
391
391
392
392
` +proj=utm +zone=18 +datum=WGS84 +units=m +no_defs +ellps=WGS84 +towgs84=0,0,0 `
@@ -416,7 +416,7 @@ can view these values:
416
416
417
417
418
418
``` r
419
- minmax(DSM_HARV )
419
+ minmax(dsm_harv )
420
420
```
421
421
422
422
``` output
@@ -426,15 +426,15 @@ max 416.07
426
426
```
427
427
428
428
``` r
429
- min(values(DSM_HARV ))
429
+ min(values(dsm_harv ))
430
430
```
431
431
432
432
``` output
433
433
[1] 305.07
434
434
```
435
435
436
436
``` r
437
- max(values(DSM_HARV ))
437
+ max(values(dsm_harv ))
438
438
```
439
439
440
440
``` output
@@ -451,7 +451,7 @@ calculated, we can calculate them using the
451
451
452
452
453
453
``` r
454
- DSM_HARV <- setMinMax(DSM_HARV )
454
+ dsm_harv <- setMinMax(dsm_harv )
455
455
```
456
456
457
457
::::::::::::::::::::::::::::::::::::::::::::::::::
@@ -461,7 +461,7 @@ We can see that the elevation at our site ranges from 305.0700073m to
461
461
462
462
## Raster Bands
463
463
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
465
465
single band raster. This means that there is only one dataset stored in the
466
466
raster: surface elevation in meters for one time period.
467
467
@@ -473,7 +473,7 @@ view the number of bands in a raster using the `nlyr()` function.
473
473
474
474
475
475
``` r
476
- nlyr(DSM_HARV )
476
+ nlyr(dsm_harv )
477
477
```
478
478
479
479
``` output
@@ -543,15 +543,15 @@ of `NA` will be ignored by R as demonstrated above.
543
543
## Challenge
544
544
545
545
Use 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.
547
547
548
548
::::::::::::::: solution
549
549
550
550
## Answers
551
551
552
552
553
553
``` r
554
- describe(sources(DSM_HARV ))
554
+ describe(sources(dsm_harv ))
555
555
```
556
556
557
557
``` output
@@ -665,7 +665,7 @@ useful in identifying outliers and bad data values in our raster data.
665
665
666
666
``` r
667
667
ggplot() +
668
- geom_histogram(data = DSM_HARV_df , aes(HARV_dsmCrop ))
668
+ geom_histogram(data = dsm_harv_df , aes(HARV_dsmCrop ))
669
669
```
670
670
671
671
``` output
@@ -685,7 +685,7 @@ by using the `bins` value in the `geom_histogram()` function.
685
685
686
686
``` r
687
687
ggplot() +
688
- geom_histogram(data = DSM_HARV_df , aes(HARV_dsmCrop ), bins = 40 )
688
+ geom_histogram(data = dsm_harv_df , aes(HARV_dsmCrop ), bins = 40 )
689
689
```
690
690
691
691
<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.
701
701
702
702
Use ` describe() ` to determine the following about the ` NEON-DS-Airborne-Remote-Sensing/HARV/DSM/HARV_DSMhill.tif ` file:
703
703
704
- 1 . Does this file have the same CRS as ` DSM_HARV ` ?
704
+ 1 . Does this file have the same CRS as ` dsm_harv ` ?
705
705
2 . What is the ` NoDataValue ` ?
706
706
3 . What is resolution of the raster data?
707
707
4 . 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")
787
787
```
788
788
789
789
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.
791
791
2 . What format ` NoDataValues ` take? -9999
792
792
3 . The resolution of the raster data? 1x1
793
793
4 . 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