Skip to content

Commit

Permalink
minor updates
Browse files Browse the repository at this point in the history
  • Loading branch information
bhass-neon committed Feb 17, 2024
1 parent 672cacc commit bef576f
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 60 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ setwd(wd)
## year='2022',
## easting=732000,
## northing=4713500,
## check.size=FALSE, # set to TRUE or can leave out if you want to check the size before downloading
## check.size=FALSE, # set to TRUE or remove if you want to check the size before downloading
## savepath = wd)


Expand All @@ -33,8 +33,6 @@ plot(DSM_HARV,


## ----classified-elevation-map, fig.cap="Classified elevation map of NEON's site Harvard Forest", fig.width=10--------------------------------------
# Demonstration image for the tutorial

# add a color map with 5 colors
col=terrain.colors(3)
# add breaks to the colormap (4 breaks = 3 segments)
Expand Down Expand Up @@ -82,20 +80,19 @@ min(DSM_HARV)
## year='2022',
## easting=737500,
## northing=4701500,
## check.size=FALSE, # set to TRUE or can leave out if you want to check the size before downloading
## check.size=FALSE, # set to TRUE or remove if you want to check the size before downloading
## savepath = wd)


## ----demonstrate-no-data-black, fig.cap="Colorized raster image with NoDataValues around the edge rendered in black"-------------------------------
# no data demonstration code - not being taught
# Use stack function to read in all bands
# 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"))

# Create an RGB image from the raster stack
# Create an RGB image from the raster
par(col.axis="white",col.lab="white",tck=0)
plotRGB(RGB_HARV, r = 1, g = 2, b = 3,
axes=TRUE, main="Raster With NoData Values\nRendered in Black")
axes=TRUE, main="Raster With NoData Values Rendered in Black")



Expand All @@ -107,7 +104,6 @@ func <- function(x) {

newRGBImage <- app(RGB_HARV, func)


par(col.axis="white",col.lab="white",tck=0)
# Create an RGB image from the raster stack
plotRGB(newRGBImage, r = 1, g = 2, b = 3,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ title: "Raster 00: Intro to Raster Data in R"
description: "This tutorial reviews the fundamental principles, packages and metadata/raster attributes that are needed to work with raster data in R. It covers the three core metadata elements that we need to understand to work with rasters in R: CRS, Extent and Resolution. It also explores missing and bad data values as stored in a raster and how R handles these elements. Finally, it introduces the GeoTiff file format."
dateCreated: 2015-10-23
authors: Leah A. Wasser, Megan A. Jones, Zack Brym, Kristina Riemer, Jason Williams, Jeff Hollister, Mike Smorul
contributors: Jason Brown
contributors: Jason Brown, Bridget Hass
estimatedTime: 1 hour
packagesLibraries: neonUtilities, terra
topics: raster, spatial-data-gis, lidar
topics: raster, spatial-data-gis, lidar, camera
languagesTool: R
dataProduct: DP3.30024.001, DP3.30010.001
code1: https://raw.githubusercontent.com/NEONScience/NEON-Data-Skills/main/tutorials/R/Geospatial-skills/intro-raster-r/00-Raster-Structure/00-Raster-Structure.R
Expand Down Expand Up @@ -77,8 +77,8 @@ Raster or "gridded" data are stored as a grid of values which are rendered on a
map as pixels. Each pixel value represents an area on the Earth's surface.

<figure>
<a href="https://raw.githubusercontent.com/NEONScience/NEON-Data-Skills/dev-aten/graphics/raster-general/raster_concept.png">
<img src="https://raw.githubusercontent.com/NEONScience/NEON-Data-Skills/dev-aten/graphics/raster-general/raster_concept.png"
<a href="https://raw.githubusercontent.com/NEONScience/NEON-Data-Skills/main/graphics/raster-general/raster_concept.png">
<img src="https://raw.githubusercontent.com/NEONScience/NEON-Data-Skills/main/graphics/raster-general/raster_concept.png"
alt="Satellite (raster) image with an inset map of a smaller extent. The inset map's structure is further shown as a grid of numeric values represented by colors on a the legend." >
</a>
<figcaption> Source: National Ecological Observatory Network (NEON)
Expand Down Expand Up @@ -107,7 +107,7 @@ byTileAOP(dpID='DP3.30024.001', # lidar elevation
year='2022',
easting=732000,
northing=4713500,
check.size=FALSE, # set to TRUE or can leave out if you want to check the size before downloading
check.size=FALSE, # set to TRUE or remove if you want to check the size before downloading
savepath = wd)
```
This file will be downloaded into a nested subdirectory under the ~/data folder, inside a folder named DP3.30024.001 (the Data Product ID). The file should show up in this location: ~/data/DP3.30024.001/neon-aop-products/2022/FullSite/D01/2022_HARV_7/L3/DiscreteLidar/DSMGtif/NEON_D01_HARV_DP3_732000_4713000_DSM.tif.
Expand Down Expand Up @@ -180,8 +180,6 @@ maps include:
The legend of this map shows the colors representing each discrete class.

```{r classified-elevation-map, fig.cap="Classified elevation map of NEON's site Harvard Forest", fig.width=10}
# Demonstration image for the tutorial
# add a color map with 5 colors
col=terrain.colors(3)
# add breaks to the colormap (4 breaks = 3 segments)
Expand Down Expand Up @@ -373,7 +371,7 @@ byTileAOP(dpID='DP3.30010.001',
year='2022',
easting=737500,
northing=4701500,
check.size=FALSE, # set to TRUE or can leave out if you want to check the size before downloading
check.size=FALSE, # set to TRUE or remove if you want to check the size before downloading
savepath = wd)
```

Expand All @@ -382,15 +380,14 @@ This file will be downloaded into a nested subdirectory under the ~/data folder,
In the image below, the pixels that are black have `NoDataValue`s. The camera did not collect data in these areas.

```{r demonstrate-no-data-black, fig.cap="Colorized raster image with NoDataValues around the edge rendered in black"}
# no data demonstration code - not being taught
# Use stack function to read in all bands
# 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"))
# Create an RGB image from the raster stack
# Create an RGB image from the raster
par(col.axis="white",col.lab="white",tck=0)
plotRGB(RGB_HARV, r = 1, g = 2, b = 3,
axes=TRUE, main="Raster With NoData Values\nRendered in Black")
axes=TRUE, main="Raster With NoData Values Rendered in Black")
```

Expand All @@ -406,7 +403,6 @@ func <- function(x) {
newRGBImage <- app(RGB_HARV, func)
par(col.axis="white",col.lab="white",tck=0)
# Create an RGB image from the raster stack
plotRGB(newRGBImage, r = 1, g = 2, b = 3,
Expand Down Expand Up @@ -437,10 +433,11 @@ Examples of Bad Data Values:
* The normalized difference vegetation index (NDVI), which is a measure of
greenness, has a valid range of -1 to 1. Any value outside of that range would
be considered a "bad" value.
* Reflectance data in an image will often range from 0-1 or 0-10,000 depending
upon how the data are scaled. Thus a value greater than 1 or greater than 10,000
* Reflectance data in an image should range from 0-1 (or 0-10,000 depending
upon how the data are scaled). Thus a value greater than 1 or greater than 10,000
is likely caused by an error in either data collection or processing. These
erroneous values can occur, for example, in water vapor absorption bands.
erroneous values can occur, for example, in water vapor absorption bands, which
contain invalid data, and are meant to be disregarded.

### Find Bad Data Values
Sometimes a raster's metadata will tell us the range of expected values for a
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@ <h2 id="about-raster-data">About Raster Data</h2>
<p>Raster or “gridded” data are stored as a grid of values which are rendered on a
map as pixels. Each pixel value represents an area on the Earth’s surface.</p>
<figure>
<a href="https://raw.githubusercontent.com/NEONScience/NEON-Data-Skills/dev-aten/graphics/raster-general/raster_concept.png">
<img src="https://raw.githubusercontent.com/NEONScience/NEON-Data-Skills/dev-aten/graphics/raster-general/raster_concept.png"
<a href="https://raw.githubusercontent.com/NEONScience/NEON-Data-Skills/main/graphics/raster-general/raster_concept.png">
<img src="https://raw.githubusercontent.com/NEONScience/NEON-Data-Skills/main/graphics/raster-general/raster_concept.png"
alt="Satellite (raster) image with an inset map of a smaller extent. The inset map's structure is further shown as a grid of numeric values represented by colors on a the legend." >
</a>
<figcaption> Source: National Ecological Observatory Network (NEON)
Expand Down Expand Up @@ -167,7 +167,7 @@ <h2 id="download-lidar-raster-data">Download LiDAR Raster Data</h2>

northing=4713500,

check.size=FALSE, # set to TRUE or can leave out if you want to check the size before downloading
check.size=FALSE, # set to TRUE or remove if you want to check the size before downloading

savepath = wd)
</code></pre>
Expand Down Expand Up @@ -247,11 +247,7 @@ <h4 id="categorical-landcover-map-for-the-united-states">Categorical Landcover M
</figure>
<h4 id="categorical-elevation-map-of-the-neon-harvard-forest-site">Categorical Elevation Map of the NEON Harvard Forest Site</h4>
<p>The legend of this map shows the colors representing each discrete class.</p>
<pre><code># Demonstration image for the tutorial



# add a color map with 5 colors
<pre><code># add a color map with 5 colors

col=terrain.colors(3)

Expand Down Expand Up @@ -449,27 +445,25 @@ <h2 id="nodata-values-in-rasters">NoData Values in Rasters</h2>

northing=4701500,

check.size=FALSE, # set to TRUE or can leave out if you want to check the size before downloading
check.size=FALSE, # set to TRUE or remove if you want to check the size before downloading

savepath = wd)
</code></pre>
<p>This file will be downloaded into a nested subdirectory under the ~/data folder, inside a folder named DP3.30010.001 (the Camera Data Product ID). The file should show up in this location: ~/data/DP3.30010.001/neon-aop-products/2022/FullSite/D01/2022_HARV_7/L3/Camera/Mosaic/2022_HARV_7_737000_4701000_image.tif.</p>
<p>In the image below, the pixels that are black have <code>NoDataValue</code>s. The camera did not collect data in these areas.</p>
<pre><code># no data demonstration code - not being taught

# Use stack function to read in all bands
<pre><code># Use rast function to read in all bands

RGB_HARV &lt;-
rast(paste0(wd,&quot;DP3.30010.001/neon-aop-products/2022/FullSite/D01/2022_HARV_7/L3/Camera/Mosaic/2022_HARV_7_737000_4701000_image.tif&quot;))



# Create an RGB image from the raster stack
# Create an RGB image from the raster

par(col.axis=&quot;white&quot;,col.lab=&quot;white&quot;,tck=0)

plotRGB(RGB_HARV, r = 1, g = 2, b = 3,
axes=TRUE, main=&quot;Raster With NoData Values\nRendered in Black&quot;)
axes=TRUE, main=&quot;Raster With NoData Values Rendered in Black&quot;)
</code></pre>
<p><img src="https://raw.githubusercontent.com/NEONScience/NEON-Data-Skills/main/tutorials/R/Geospatial-skills/intro-raster-r/00-Raster-Structure/rfigs/demonstrate-no-data-black-1.png" alt="Colorized raster image with NoDataValues around the edge rendered in black" /></p>
<p>In the next image, the black edges have been assigned <code>NoDataValue</code>. R doesn’t
Expand Down Expand Up @@ -514,10 +508,11 @@ <h2 id="bad-data-values-in-rasters">Bad Data Values in Rasters</h2>
<li>The normalized difference vegetation index (NDVI), which is a measure of
greenness, has a valid range of -1 to 1. Any value outside of that range would
be considered a “bad” value.</li>
<li>Reflectance data in an image will often range from 0-1 or 0-10,000 depending
upon how the data are scaled. Thus a value greater than 1 or greater than 10,000
<li>Reflectance data in an image should range from 0-1 (or 0-10,000 depending
upon how the data are scaled). Thus a value greater than 1 or greater than 10,000
is likely caused by an error in either data collection or processing. These
erroneous values can occur, for example, in water vapor absorption bands.</li>
erroneous values can occur, for example, in water vapor absorption bands, which
contain invalid data, and are meant to be disregarded.</li>
</ul>
<h3 id="find-bad-data-values">Find Bad Data Values</h3>
<p>Sometimes a raster’s metadata will tell us the range of expected values for a
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ title: "Raster 00: Intro to Raster Data in R"
description: "This tutorial reviews the fundamental principles, packages and metadata/raster attributes that are needed to work with raster data in R. It covers the three core metadata elements that we need to understand to work with rasters in R: CRS, Extent and Resolution. It also explores missing and bad data values as stored in a raster and how R handles these elements. Finally, it introduces the GeoTiff file format."
dateCreated: 2015-10-23
authors: Leah A. Wasser, Megan A. Jones, Zack Brym, Kristina Riemer, Jason Williams, Jeff Hollister, Mike Smorul
contributors: Jason Brown
contributors: Jason Brown, Bridget Hass
estimatedTime: 1 hour
packagesLibraries: neonUtilities, terra
topics: raster, spatial-data-gis, lidar
topics: raster, spatial-data-gis, lidar, camera
languagesTool: R
dataProduct: DP3.30024.001, DP3.30010.001
code1: https://raw.githubusercontent.com/NEONScience/NEON-Data-Skills/main/tutorials/R/Geospatial-skills/intro-raster-r/00-Raster-Structure/00-Raster-Structure.R
Expand Down Expand Up @@ -77,8 +77,8 @@ Raster or "gridded" data are stored as a grid of values which are rendered on a
map as pixels. Each pixel value represents an area on the Earth's surface.

<figure>
<a href="https://raw.githubusercontent.com/NEONScience/NEON-Data-Skills/dev-aten/graphics/raster-general/raster_concept.png">
<img src="https://raw.githubusercontent.com/NEONScience/NEON-Data-Skills/dev-aten/graphics/raster-general/raster_concept.png"
<a href="https://raw.githubusercontent.com/NEONScience/NEON-Data-Skills/main/graphics/raster-general/raster_concept.png">
<img src="https://raw.githubusercontent.com/NEONScience/NEON-Data-Skills/main/graphics/raster-general/raster_concept.png"
alt="Satellite (raster) image with an inset map of a smaller extent. The inset map's structure is further shown as a grid of numeric values represented by colors on a the legend." >
</a>
<figcaption> Source: National Ecological Observatory Network (NEON)
Expand Down Expand Up @@ -115,7 +115,7 @@ We can use the neonUtilities function byTileAOP to download a single elevation t

northing=4713500,

check.size=FALSE, # set to TRUE or can leave out if you want to check the size before downloading
check.size=FALSE, # set to TRUE or remove if you want to check the size before downloading

savepath = wd)
This file will be downloaded into a nested subdirectory under the ~/data folder, inside a folder named DP3.30024.001 (the Data Product ID). The file should show up in this location: ~/data/DP3.30024.001/neon-aop-products/2022/FullSite/D01/2022_HARV_7/L3/DiscreteLidar/DSMGtif/NEON_D01_HARV_DP3_732000_4713000_DSM.tif.
Expand Down Expand Up @@ -206,10 +206,6 @@ maps include:
The legend of this map shows the colors representing each discrete class.


# Demonstration image for the tutorial



# add a color map with 5 colors

col=terrain.colors(3)
Expand Down Expand Up @@ -439,7 +435,7 @@ Let's take a look at some of the RGB Camera data over HARV, this time downloadin

northing=4701500,

check.size=FALSE, # set to TRUE or can leave out if you want to check the size before downloading
check.size=FALSE, # set to TRUE or remove if you want to check the size before downloading

savepath = wd)

Expand All @@ -448,21 +444,19 @@ This file will be downloaded into a nested subdirectory under the ~/data folder,
In the image below, the pixels that are black have `NoDataValue`s. The camera did not collect data in these areas.


# no data demonstration code - not being taught

# Use stack function to read in all bands
# 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"))



# Create an RGB image from the raster stack
# Create an RGB image from the raster

par(col.axis="white",col.lab="white",tck=0)

plotRGB(RGB_HARV, r = 1, g = 2, b = 3,
axes=TRUE, main="Raster With NoData Values\nRendered in Black")
axes=TRUE, main="Raster With NoData Values Rendered in Black")

![Colorized raster image with NoDataValues around the edge rendered in black](https://raw.githubusercontent.com/NEONScience/NEON-Data-Skills/main/tutorials/R/Geospatial-skills/intro-raster-r/00-Raster-Structure/rfigs/demonstrate-no-data-black-1.png)

Expand Down Expand Up @@ -515,10 +509,11 @@ Examples of Bad Data Values:
* The normalized difference vegetation index (NDVI), which is a measure of
greenness, has a valid range of -1 to 1. Any value outside of that range would
be considered a "bad" value.
* Reflectance data in an image will often range from 0-1 or 0-10,000 depending
upon how the data are scaled. Thus a value greater than 1 or greater than 10,000
* Reflectance data in an image should range from 0-1 (or 0-10,000 depending
upon how the data are scaled). Thus a value greater than 1 or greater than 10,000
is likely caused by an error in either data collection or processing. These
erroneous values can occur, for example, in water vapor absorption bands.
erroneous values can occur, for example, in water vapor absorption bands, which
contain invalid data, and are meant to be disregarded.

### Find Bad Data Values
Sometimes a raster's metadata will tell us the range of expected values for a
Expand Down

0 comments on commit bef576f

Please sign in to comment.