Skip to content

Commit

Permalink
fix figure legends that were cut off, minor updates, remove NOT_VERIF…
Browse files Browse the repository at this point in the history
…IED.txt
  • Loading branch information
bhass-neon committed Nov 29, 2023
1 parent 7161b34 commit 05e1537
Show file tree
Hide file tree
Showing 12 changed files with 75 additions and 83 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ DTM_post_hillshade <- shade(DTM_post_slope, DTM_post_aspect)



## ----plot-rasters, fig.cap=c("Raster Plot of Four Mile Creek, Boulder County, Pre-Flood. This figure combines the DTM and hillshade raster objects into one plot.","Raster Plot of Four Mile Creek, Boulder County, Post-Flood. This figure combines the DTM and hillshade raster objects into one plot.")----
## ----plot-rasters, fig.dim = c(7, 6), fig.align = 'left', fig.cap=c("Raster Plot of Four Mile Creek, Boulder County, Pre-Flood. This figure combines the DTM and hillshade raster objects into one plot.","Raster Plot of Four Mile Creek, Boulder County, Post-Flood. This figure combines the DTM and hillshade raster objects into one plot.")----

# plot Pre-flood w/ hillshade
plot(DTM_pre_hillshade,
col=grey(1:90/100), # create a color ramp of grey colors for hillshade
legend=FALSE, # no legend, we don't care about the grey of the hillshade
main="Pre-Flood Four Mile Canyon, Boulder County",
legend=FALSE, # no legend, we don't care about the values of the hillshade
main="Pre-Flood DEM: Four Mile Canyon, Boulder County",
axes=FALSE) # makes for a cleaner plot, if the coordinates aren't necessary

plot(DTM_pre,
Expand All @@ -49,11 +49,10 @@ plot(DTM_pre,
add=TRUE) # add=TRUE (or T), add plot to the previous plotting frame

# plot Post-flood w/ hillshade
# note, no add=T in this code, so new plotting frame.
plot(DTM_post_hillshade,
col=grey(1:90/100),
legend=FALSE,
main="Post-Flood Four Mile Canyon, Boulder County",
main="Post-Flood DEM: Four Mile Canyon, Boulder County",
axes=FALSE)

plot(DTM_post,
Expand All @@ -63,7 +62,7 @@ plot(DTM_post,



## ----create-difference-model, fig.cap= "Digital Elevation Model of Difference showing the difference between digital elevation models (DTM)."----------
## ----create-difference-model, fig.dim = c(7, 6), fig.align = 'left', fig.cap= "Digital Elevation Model of Difference showing the difference between digital elevation models (DTM)."----
# DoD: erosion to be neg, deposition to be positive, therefore post - pre
DoD <- DTM_post-DTM_pre

Expand All @@ -79,7 +78,7 @@ hist(DoD)



## ----pretty-diff-model, fig.cap= "Plot of the Elevation change Post-flood in Four Mile Canyon Creek, Boulder County with elevation change represented in categories (breaks)."----
## ----pretty-diff-model, fig.dim = c(7.5, 6), fig.align = 'left', fig.cap= "Plot of the Elevation change Post-flood in Four Mile Canyon Creek, Boulder County with elevation change represented in categories (breaks)."----
# Color palette for 5 categories
difCol5 = c("#d7191c","#fdae61","#ffffbf","#abd9e9","#2c7bb6")

Expand All @@ -90,7 +89,7 @@ difCol5 = c("#d7191c","#fdae61","#ffffbf","#abd9e9","#2c7bb6")
plot(DTM_post_hillshade,
col=grey(1:90/100), # create a color ramp of grey colors
legend=FALSE,
main="Elevation Change Post-Flood Four Mile Canyon, Boulder County",
main="Elevation Change Post-Flood: Four Mile Canyon, Boulder County",
axes=FALSE)

# add the DoD to it with specified breaks & colors
Expand All @@ -103,12 +102,12 @@ plot(DoD,



## ----crop-raster-man,fig.cap= "Plot of the Elevation change Post-flood in Four Mile Canyon Creek, Boulder County. Figure also includes crop window inlay around the area of interest.", eval=FALSE, comment=NA----
## ----crop-raster-man, fig.dim = c(7, 6), fig.align = 'left', fig.cap= "Plot of the Elevation change Post-flood in Four Mile Canyon Creek, Boulder County. Figure also includes crop window inlay around the area of interest.", eval=FALSE, comment=NA----
# plot the rasters you want to crop from
plot(DTM_post_hillshade,
col=grey(1:90/100), # create a color ramp of grey colors
legend=FALSE,
main="Pre-Flood Four Mile Canyon, Boulder County",
main="Pre-Flood Elevation: Four Mile Canyon, Boulder County",
axes=FALSE)

plot(DoD,
Expand All @@ -135,7 +134,7 @@ cropbox1
cropbox2 <- c(473792.6,474999,4434526,4435453)


## ----plot-crop-raster, fig.cap=c("Raster Plot of the cropped section of Four Mile Creek, Boulder County.","Raster Plot of the cropped section of Four Mile Creek, Boulder County, Post-Flood.","Plot of the Elevation change, Post-flood, in the cropped section of Four Mile Canyon Creek, Boulder County with elevation change represented in categories (breaks).")----
## ----plot-crop-raster, fig.dim = c(9, 6), fig.align = 'left', fig.cap=c("Raster Plot of the cropped section of Four Mile Creek, Boulder County.","Raster Plot of the cropped section of Four Mile Creek, Boulder County, Post-Flood.","Plot of the Elevation change, Post-flood, in the cropped section of Four Mile Canyon Creek, Boulder County with elevation change represented in categories (breaks).")----

# crop desired layers to the cropbox2 extent
DTM_pre_crop <- crop(DTM_pre, cropbox2)
Expand All @@ -148,9 +147,9 @@ DoD_crop <- crop(DoD, cropbox2)

# PRE-FLOOD (w/ hillshade)
plot(DTMpre_hill_crop,
col=grey(1:90/100), # create a color ramp of grey colors
col=grey(1:90/100), # create a color ramp of grey colors:
legend=FALSE,
main="Pre-Flood Four Mile Canyon, Boulder County ",
main="Pre-Flood Elevation: Four Mile Canyon, Boulder County ",
axes=FALSE)

plot(DTM_pre_crop,
Expand All @@ -162,7 +161,7 @@ plot(DTM_pre_crop,
plot(DTMpost_hill_crop,
col=grey(1:90/100), # create a color ramp of grey colors
legend=FALSE,
main="Post-Flood Four Mile Canyon, Boulder County",
main="Post-Flood Elevation: Four Mile Canyon, Boulder County",
axes=FALSE)

plot(DTM_post_crop,
Expand All @@ -174,7 +173,7 @@ plot(DTM_post_crop,
plot(DTMpost_hill_crop,
col=grey(1:90/100), # create a color ramp of grey colors
legend=FALSE,
main="Elevation Change Post Flood Four Mile Canyon, Boulder County",
main="Post-Flood Elevation Change: Four Mile Canyon, Boulder County",
axes=FALSE)

plot(DoD_crop,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,13 +169,13 @@ when plotting the second plot. To be able to see the first (hillshade) plot,
through the second (DTM) plot, we also set a value between 0 (transparent) and 1
(not transparent) for the `alpha=` argument.

```{r plot-rasters, fig.cap=c("Raster Plot of Four Mile Creek, Boulder County, Pre-Flood. This figure combines the DTM and hillshade raster objects into one plot.","Raster Plot of Four Mile Creek, Boulder County, Post-Flood. This figure combines the DTM and hillshade raster objects into one plot.") }
```{r plot-rasters, fig.dim = c(7, 6), fig.align = 'left', fig.cap=c("Raster Plot of Four Mile Creek, Boulder County, Pre-Flood. This figure combines the DTM and hillshade raster objects into one plot.","Raster Plot of Four Mile Creek, Boulder County, Post-Flood. This figure combines the DTM and hillshade raster objects into one plot.") }
# plot Pre-flood w/ hillshade
plot(DTM_pre_hillshade,
col=grey(1:90/100), # create a color ramp of grey colors for hillshade
legend=FALSE, # no legend, we don't care about the grey of the hillshade
main="Pre-Flood Four Mile Canyon, Boulder County",
legend=FALSE, # no legend, we don't care about the values of the hillshade
main="Pre-Flood DEM: Four Mile Canyon, Boulder County",
axes=FALSE) # makes for a cleaner plot, if the coordinates aren't necessary
plot(DTM_pre,
Expand All @@ -184,11 +184,10 @@ plot(DTM_pre,
add=TRUE) # add=TRUE (or T), add plot to the previous plotting frame
# plot Post-flood w/ hillshade
# note, no add=T in this code, so new plotting frame.
plot(DTM_post_hillshade,
col=grey(1:90/100),
legend=FALSE,
main="Post-Flood Four Mile Canyon, Boulder County",
main="Post-Flood DEM: Four Mile Canyon, Boulder County",
axes=FALSE)
plot(DTM_post,
Expand All @@ -211,7 +210,7 @@ A **D**igital Elevation Model **o**f **D**ifference (DoD) is a model of the
change (or difference) between two other digital elevation models - in our case
DTMs.

```{r create-difference-model, fig.cap= "Digital Elevation Model of Difference showing the difference between digital elevation models (DTM)." }
```{r create-difference-model, fig.dim = c(7, 6), fig.align = 'left', fig.cap= "Digital Elevation Model of Difference showing the difference between digital elevation models (DTM)."}
# DoD: erosion to be neg, deposition to be positive, therefore post - pre
DoD <- DTM_post-DTM_pre
Expand Down Expand Up @@ -259,7 +258,7 @@ that vector with the `col=` argument in the `plot()` function to specify these.

Let's now implement these two changes in our code.

```{r pretty-diff-model, fig.cap= "Plot of the Elevation change Post-flood in Four Mile Canyon Creek, Boulder County with elevation change represented in categories (breaks)." }
```{r pretty-diff-model, fig.dim = c(7.5, 6), fig.align = 'left', fig.cap= "Plot of the Elevation change Post-flood in Four Mile Canyon Creek, Boulder County with elevation change represented in categories (breaks)."}
# Color palette for 5 categories
difCol5 = c("#d7191c","#fdae61","#ffffbf","#abd9e9","#2c7bb6")
Expand All @@ -270,7 +269,7 @@ difCol5 = c("#d7191c","#fdae61","#ffffbf","#abd9e9","#2c7bb6")
plot(DTM_post_hillshade,
col=grey(1:90/100), # create a color ramp of grey colors
legend=FALSE,
main="Elevation Change Post-Flood Four Mile Canyon, Boulder County",
main="Elevation Change Post-Flood: Four Mile Canyon, Boulder County",
axes=FALSE)
# add the DoD to it with specified breaks & colors
Expand All @@ -297,12 +296,12 @@ by manually drawing a box.

#### Method 1: Manually draw cropbox

```{r crop-raster-man,fig.cap= "Plot of the Elevation change Post-flood in Four Mile Canyon Creek, Boulder County. Figure also includes crop window inlay around the area of interest.", eval=FALSE, comment=NA}
```{r crop-raster-man, fig.dim = c(7, 6), fig.align = 'left', fig.cap= "Plot of the Elevation change Post-flood in Four Mile Canyon Creek, Boulder County. Figure also includes crop window inlay around the area of interest.", eval=FALSE, comment=NA}
# plot the rasters you want to crop from
plot(DTM_post_hillshade,
col=grey(1:90/100), # create a color ramp of grey colors
legend=FALSE,
main="Pre-Flood Four Mile Canyon, Boulder County",
main="Pre-Flood Elevation: Four Mile Canyon, Boulder County",
axes=FALSE)
plot(DoD,
Expand All @@ -328,7 +327,7 @@ cropbox1 <- c(473814, 474982, 4434537, 4435390)

After executing the `draw()` function, we now physically click on the plot
at the two opposite corners of the box you want to crop to. You should see a
box drawn on the plot at this point.
red bordered polygon display on the raster at this point.

When we call this new object, we can view the new extent.

Expand All @@ -339,23 +338,23 @@ cropbox1
```

It is a good idea to write this new extent down, so that you can use the extent
again the next time you use the script.
again the next time you run the script.

#### Method 2: Define the cropbox

If you know the desired extent of the object you can also use it to crop the box,
by creating an object that is a vector of the x min, x max, y min, and y max of
the desired area.
by creating an object that is a vector containing the four vertices (x min,
x max, y min, and y max) of the polygon.

```{r crop-raster-coords}
# desired coordinates of the box
cropbox2 <- c(473792.6,474999,4434526,4435453)
```

Once you have the crop box defined, either by manually clicking or by defining
Once you have the crop box defined, either by manually clicking or by setting
the coordinates, you can crop the desired layer to the crop box.

```{r plot-crop-raster, fig.cap=c("Raster Plot of the cropped section of Four Mile Creek, Boulder County.","Raster Plot of the cropped section of Four Mile Creek, Boulder County, Post-Flood.","Plot of the Elevation change, Post-flood, in the cropped section of Four Mile Canyon Creek, Boulder County with elevation change represented in categories (breaks).")}
```{r plot-crop-raster, fig.dim = c(9, 6), fig.align = 'left', fig.cap=c("Raster Plot of the cropped section of Four Mile Creek, Boulder County.","Raster Plot of the cropped section of Four Mile Creek, Boulder County, Post-Flood.","Plot of the Elevation change, Post-flood, in the cropped section of Four Mile Canyon Creek, Boulder County with elevation change represented in categories (breaks).")}
# crop desired layers to the cropbox2 extent
DTM_pre_crop <- crop(DTM_pre, cropbox2)
Expand All @@ -368,9 +367,9 @@ DoD_crop <- crop(DoD, cropbox2)
# PRE-FLOOD (w/ hillshade)
plot(DTMpre_hill_crop,
col=grey(1:90/100), # create a color ramp of grey colors
col=grey(1:90/100), # create a color ramp of grey colors:
legend=FALSE,
main="Pre-Flood Four Mile Canyon, Boulder County ",
main="Pre-Flood Elevation: Four Mile Canyon, Boulder County ",
axes=FALSE)
plot(DTM_pre_crop,
Expand All @@ -382,7 +381,7 @@ plot(DTM_pre_crop,
plot(DTMpost_hill_crop,
col=grey(1:90/100), # create a color ramp of grey colors
legend=FALSE,
main="Post-Flood Four Mile Canyon, Boulder County",
main="Post-Flood Elevation: Four Mile Canyon, Boulder County",
axes=FALSE)
plot(DTM_post_crop,
Expand All @@ -394,7 +393,7 @@ plot(DTM_post_crop,
plot(DTMpost_hill_crop,
col=grey(1:90/100), # create a color ramp of grey colors
legend=FALSE,
main="Elevation Change Post Flood Four Mile Canyon, Boulder County",
main="Post-Flood Elevation Change: Four Mile Canyon, Boulder County",
axes=FALSE)
plot(DoD_crop,
Expand Down
Loading

0 comments on commit 05e1537

Please sign in to comment.