Skip to content

Commit

Permalink
differences for PR #444
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user committed Jun 15, 2024
1 parent 273f577 commit 383e8a2
Show file tree
Hide file tree
Showing 9 changed files with 86 additions and 41 deletions.
20 changes: 17 additions & 3 deletions 01-raster-structure.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,17 @@ source: Rmd
---


``` warning
Warning in
download.file("https://www.naturalearthdata.com/http//www.naturalearthdata.com/download/110m/physical/ne_110m_graticules_all.zip",
: cannot open URL
'https://www.naturalearthdata.com/http//www.naturalearthdata.com/download/110m/physical/ne_110m_graticules_all.zip':
HTTP status was '500 Internal Server Error'
```

``` error
Error in download.file("https://www.naturalearthdata.com/http//www.naturalearthdata.com/download/110m/physical/ne_110m_graticules_all.zip", : cannot open URL 'https://www.naturalearthdata.com/http//www.naturalearthdata.com/download/110m/physical/ne_110m_graticules_all.zip'
```

::::::::::::::::::::::::::::::::::::::: objectives

Expand Down Expand Up @@ -463,7 +474,7 @@ raster: surface elevation in meters for one time period.

A raster dataset can contain one or more bands. We can use the `rast()`
function to import one single band from a single or multi-band raster. We can
view the number of bands in a raster using the `nlyr()` function.
view the number of bands in a raster using the `nly()` function.


``` r
Expand All @@ -474,8 +485,11 @@ nlyr(DSM_HARV)
[1] 1
```

However, raster data can also be multi-band, meaning that one raster file contains data for more than one variable or time period for each cell.
Jump to a later episode in this series for information on working with multi-band rasters:
However, raster data can also be multi-band, meaning that one raster file
contains data for more than one variable or time period for each cell. By
default the `raster()` function only imports the first band in a raster
regardless of whether it has one or more bands. Jump to a later episode in
this series for information on working with multi-band rasters:
[Work with Multi-band Rasters in R](05-raster-multi-band-in-r/).

## Dealing with Missing Data
Expand Down
38 changes: 29 additions & 9 deletions 02-raster-plot.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,17 @@ source: Rmd
---


``` warning
Warning in
download.file("https://www.naturalearthdata.com/http//www.naturalearthdata.com/download/110m/physical/ne_110m_graticules_all.zip",
: cannot open URL
'https://www.naturalearthdata.com/http//www.naturalearthdata.com/download/110m/physical/ne_110m_graticules_all.zip':
HTTP status was '500 Internal Server Error'
```

``` error
Error in download.file("https://www.naturalearthdata.com/http//www.naturalearthdata.com/download/110m/physical/ne_110m_graticules_all.zip", : cannot open URL 'https://www.naturalearthdata.com/http//www.naturalearthdata.com/download/110m/physical/ne_110m_graticules_all.zip'
```

::::::::::::::::::::::::::::::::::::::: objectives

Expand Down Expand Up @@ -79,19 +90,24 @@ unique(DSM_HARV_df$fct_elevation)
Levels: (305,342] (342,379] (379,416]
```

And we can get the count of values in each group using `dplyr`'s `count()` function:
And we can get the count of values in each group using `dplyr`'s `group_by()`
and `count()` functions:


``` r
DSM_HARV_df %>%
count(fct_elevation)
group_by(fct_elevation) %>%
count()
```

``` output
# A tibble: 3 × 2
# Groups: fct_elevation [3]
fct_elevation n
1 (305,342] 418891
2 (342,379] 1530073
3 (379,416] 370835
<fct> <int>
1 (305,342] 418891
2 (342,379] 1530073
3 (379,416] 370835
```

We might prefer to customize the cutoff values for these groups.
Expand Down Expand Up @@ -143,14 +159,18 @@ And we can get the count of values in each group in the same way we did before:

``` r
DSM_HARV_df %>%
count(fct_elevation_2)
group_by(fct_elevation_2) %>%
count()
```

``` output
# A tibble: 3 × 2
# Groups: fct_elevation_2 [3]
fct_elevation_2 n
1 (300,350] 741815
2 (350,400] 1567316
3 (400,450] 10668
<fct> <int>
1 (300,350] 741815
2 (350,400] 1567316
3 (400,450] 10668
```

We can use those groups to plot our raster data, with each group being a
Expand Down
15 changes: 13 additions & 2 deletions 05-raster-multi-band-in-r.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,17 @@ source: Rmd
---


``` warning
Warning in
download.file("https://www.naturalearthdata.com/http//www.naturalearthdata.com/download/110m/physical/ne_110m_graticules_all.zip",
: cannot open URL
'https://www.naturalearthdata.com/http//www.naturalearthdata.com/download/110m/physical/ne_110m_graticules_all.zip':
HTTP status was '500 Internal Server Error'
```

``` error
Error in download.file("https://www.naturalearthdata.com/http//www.naturalearthdata.com/download/110m/physical/ne_110m_graticules_all.zip", : cannot open URL 'https://www.naturalearthdata.com/http//www.naturalearthdata.com/download/110m/physical/ne_110m_graticules_all.zip'
```

::::::::::::::::::::::::::::::::::::::: objectives

Expand Down Expand Up @@ -49,7 +60,7 @@ Each RGB image is a 3-band raster. The same steps would apply to working with a
multi-spectral image with 4 or more bands - like Landsat imagery.

By using the `rast()` function along with the `lyrs` parameter, we can read
specific raster bands (i.e. the first one); omitting this parameter would read
specific raster bands (i.e. the first one); omitting this parater would read
instead all bands.


Expand Down Expand Up @@ -364,7 +375,7 @@ well between 0 and 255.
Let's explore what happens with NoData values when working with RasterStack
objects and using the `plotRGB()` function. We will use the
`HARV_Ortho_wNA.tif` GeoTIFF file in the
`NEON-DS-Airborne-Remote-Sensing/HARVRGB_Imagery/` directory.
`NEON-DS-Airborne-Remote-Sensing/HARV/RGB_Imagery/` directory.

1. View the files attributes. Are there `NoData` values assigned for this file?
2. If so, what is the `NoData` Value?
Expand Down
Empty file modified fig/dc-spatial-raster/GreennessOverTime.jpg
100755 → 100644
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified fig/dc-spatial-raster/RGBSTack_1.jpg
100755 → 100644
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified fig/dc-spatial-raster/UTM_zones_18-19.jpg
100755 → 100644
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified fig/dc-spatial-raster/spatial_extent.png
100755 → 100644
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions md5sum.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
"about.md" "2ae9402fd9f37560bd85430a98bf4847" "site/built/about.md" "2024-06-04"
"config.yaml" "8f4c7a49b9d32beef686bcd8ae3e4c5f" "site/built/config.yaml" "2024-06-04"
"index.md" "8704017272467874007912c316744a00" "site/built/index.md" "2024-06-04"
"episodes/01-raster-structure.Rmd" "fd0024d668eb41109e4761a558c3d855" "site/built/01-raster-structure.md" "2024-06-15"
"episodes/02-raster-plot.Rmd" "5de487340aa50257089b12295059018b" "site/built/02-raster-plot.md" "2024-06-15"
"episodes/01-raster-structure.Rmd" "c819b6903d870befad6add128c4f9274" "site/built/01-raster-structure.md" "2024-06-15"
"episodes/02-raster-plot.Rmd" "3bc30659ae4d91c31a1175ff7127531a" "site/built/02-raster-plot.md" "2024-06-15"
"episodes/03-raster-reproject-in-r.Rmd" "d11ff839db427f11b0f0d5e8f7825c80" "site/built/03-raster-reproject-in-r.md" "2024-06-04"
"episodes/04-raster-calculations-in-r.Rmd" "a100233c7c80bcae34c0112d10980d0d" "site/built/04-raster-calculations-in-r.md" "2024-06-04"
"episodes/05-raster-multi-band-in-r.Rmd" "ed98c238c11fbe7706bf924813f17d20" "site/built/05-raster-multi-band-in-r.md" "2024-06-15"
"episodes/05-raster-multi-band-in-r.Rmd" "575875af5ca9a106473a84c1fc41804d" "site/built/05-raster-multi-band-in-r.md" "2024-06-15"
"episodes/06-vector-open-shapefile-in-r.Rmd" "9966d5678aea06e445f5b660a079482e" "site/built/06-vector-open-shapefile-in-r.md" "2024-06-04"
"episodes/07-vector-shapefile-attributes-in-r.Rmd" "726f78cdabe6ebe90a609b31127674ca" "site/built/07-vector-shapefile-attributes-in-r.md" "2024-06-04"
"episodes/08-vector-plot-shapefiles-custom-legend.Rmd" "733bf768d8f27d9c7e548e7f835fda67" "site/built/08-vector-plot-shapefiles-custom-legend.md" "2024-06-04"
Expand Down
48 changes: 24 additions & 24 deletions setup.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,43 +2,43 @@ options(timeout = max(300, getOption('timeout')))
## file structure

if (! file.exists("data/NEON-DS-Site-Layout-Files")) {
dest <- tempfile()
download.file("https://ndownloader.figshare.com/files/3708751", dest,
mode = "wb")
unzip(dest, exdir = "data")
dest <- tempfile()
download.file("https://ndownloader.figshare.com/files/3708751", dest,
mode = "wb")
unzip(dest, exdir = "data")
}

if (! file.exists("data/NEON-DS-Airborne-Remote-Sensing")) {
dest <- tempfile()
download.file("https://ndownloader.figshare.com/files/3701578", dest,
mode = "wb")
unzip(dest, exdir = "data")
dest <- tempfile()
download.file("https://ndownloader.figshare.com/files/3701578", dest,
mode = "wb")
unzip(dest, exdir = "data")
}

if (! file.exists("data/NEON-DS-Met-Time-Series")) {
dest <- tempfile()
download.file("https://ndownloader.figshare.com/files/3701572", dest,
mode = "wb")
unzip(dest, exdir = "data")
dest <- tempfile()
download.file("https://ndownloader.figshare.com/files/3701572", dest,
mode = "wb")
unzip(dest, exdir = "data")
}

if (! file.exists("data/NEON-DS-Landsat-NDVI")) {
dest <- tempfile()
download.file("https://ndownloader.figshare.com/files/4933582", dest,
mode = "wb")
unzip(dest, exdir = "data")
dest <- tempfile()
download.file("https://ndownloader.figshare.com/files/4933582", dest,
mode = "wb")
unzip(dest, exdir = "data")
}

if (! file.exists("data/Global/Boundaries/ne_110m_graticules_all")) {
dest <- tempfile()
download.file("https://naciscdn.org/naturalearth/110m/physical/ne_110m_graticules_all.zip",
dest, mode = "wb")
unzip(dest, exdir = "data/Global/Boundaries/ne_110m_graticules_all")
dest <- tempfile()
download.file("https://www.naturalearthdata.com/http//www.naturalearthdata.com/download/110m/physical/ne_110m_graticules_all.zip",
dest, mode = "wb")
unzip(dest, exdir = "data/Global/Boundaries/ne_110m_graticules_all")
}

if (! file.exists("data/Global/Boundaries/ne_110m_land")) {
dest <- tempfile()
download.file("https://naciscdn.org/naturalearth/110m/physical/ne_110m_land.zip",
dest, mode = "wb")
unzip(dest, exdir = "data/Global/Boundaries/ne_110m_land")
dest <- tempfile()
download.file("https://www.naturalearthdata.com/http//www.naturalearthdata.com/download/110m/physical/ne_110m_land.zip",
dest, mode = "wb")
unzip(dest, exdir = "data/Global/Boundaries/ne_110m_land")
}

0 comments on commit 383e8a2

Please sign in to comment.