@@ -192,43 +192,26 @@ site.clip <- as(site.poly,"Spatial")
192192
193193These are the names of the full field RGB data for the month of May.
194194We will be extracting our plot data from these files.
195- A compressed file containing these images can be found on [ Google Drive ] ( https://drive.google.com/file/d/1UuVHHcyf9sxjX9fEUpD4qa9LGlBR0XnK/view?usp=sharing ) .
196- Be sure to extract the image files into a folder that's accessible to the code below.
195+ A compressed file containing these images can be found on [ Clowder ] ( https://terraref.ncsa.illinois.edu/clowder/files/5c8175874f0c78f6486d6870?dataset=5c81709a4f0c78f6486d686c&space= ) .
196+ The code below downloads the image files into a .zip file, which takes a few minutes, and then unzips that file so the image files are accessible.
197197
198198``` {r synth_filename_array}
199- image_files <-
200- c('fullfield_L1_ua-mac_2018-05-01_rgb_stereovis_ir_sensors_fullfield_sorghum6_shade_may2018_thumb.tif',
201- 'fullfield_L1_ua-mac_2018-05-02_rgb_stereovis_ir_sensors_fullfield_sorghum6_shade_may2018_thumb.tif',
202- 'fullfield_L1_ua-mac_2018-05-03_rgb_stereovis_ir_sensors_fullfield_sorghum6_shade_may2018_thumb.tif',
203- 'fullfield_L1_ua-mac_2018-05-05_rgb_stereovis_ir_sensors_fullfield_sorghum6_shade_may2018_thumb.tif',
204- 'fullfield_L1_ua-mac_2018-05-06_rgb_stereovis_ir_sensors_fullfield_sorghum6_shade_may2018_thumb.tif',
205- 'fullfield_L1_ua-mac_2018-05-08_rgb_stereovis_ir_sensors_fullfield_sorghum6_shade_may2018_thumb.tif',
206- 'fullfield_L1_ua-mac_2018-05-09_rgb_stereovis_ir_sensors_fullfield_sorghum6_shade_may2018_thumb.tif',
207- 'fullfield_L1_ua-mac_2018-05-10_rgb_stereovis_ir_sensors_fullfield_sorghum6_sun_may2018_-_copy_thumb.tif',
208- 'fullfield_L1_ua-mac_2018-05-12_rgb_stereovis_ir_sensors_fullfield_sorghum6_shade_may2018_thumb.tif',
209- 'fullfield_L1_ua-mac_2018-05-13_rgb_stereovis_ir_sensors_fullfield_sorghum6_shade_may2018_thumb.tif',
210- 'fullfield_L1_ua-mac_2018-05-14_rgb_stereovis_ir_sensors_fullfield_sorghum6_shade_may2018_thumb.tif',
211- 'fullfield_L1_ua-mac_2018-05-15_rgb_stereovis_ir_sensors_fullfield_sorghum6_sun_may2018_thumb.tif',
212- 'fullfield_L1_ua-mac_2018-05-17_rgb_stereovis_ir_sensors_fullfield_sorghum6_shade_may2018_thumb.tif',
213- 'fullfield_L1_ua-mac_2018-05-18_rgb_stereovis_ir_sensors_fullfield_sorghum6_sun_may2018_thumb.tif',
214- 'fullfield_L1_ua-mac_2018-05-20_rgb_stereovis_ir_sensors_plots_sorghum6_shade_thumb.tif',
215- 'fullfield_L1_ua-mac_2018-05-21_rgb_stereovis_ir_sensors_fullfield_sorghum6_shade_may2018_thumb.tif',
216- 'fullfield_L1_ua-mac_2018-05-22_rgb_stereovis_ir_sensors_plots_sorghum6_sun_thumb.tif',
217- 'fullfield_L1_ua-mac_2018-05-23_rgb_stereovis_ir_sensors_plots_sorghum6_sun_thumb.tif',
218- 'fullfield_L1_ua-mac_2018-05-28_rgb_stereovis_ir_sensors_plots_sorghum6_shade_rgb_eastedge_mn_thumb.tif'
219- )
220- ```
221-
222- ``` {r, echo = F}
223- image_files_paths <- file.path("vignettes/", image_files)
199+ if(!file.exists("rgb_images.zip")){
200+ download.file("https://terraref.ncsa.illinois.edu/clowder/files/5c8175874f0c78f6486d6870/blob", destfile = "rgb_images.zip")
201+ unzip("rgb_images.zip", exdir = ".")
202+ }
224203```
225204
226205We will loop through these images, extract our plot data, and calculate the "greeness" of each extract.
227206We are using the name of the file to extract the date for later.
228207
229- ``` {r synth_get_greeness}
208+ ``` {r synth_get_greeness, message=FALSE }
230209library(raster)
231210
211+ # Get file paths for all image files
212+ image_files <- list.files(".", pattern = "*.tif")
213+ image_files_paths <- file.path(".", image_files)
214+
232215# Extract the date from the file name
233216getDate <- function(file_name){
234217 date <- str_match_all(file_name, '[0-9]{4}-[0-9]{2}-[0-9]{2}')[[1]][,1]
@@ -270,9 +253,9 @@ We then pull in the canopy data for our charting purposes.
270253
271254``` {r get_trait_data_2, message = FALSE}
272255trait_canopy_cover <- betydb_query(table = "search",
273- trait = "canopy_cover",
274- date = "~2018 May",
275- limit = "none")
256+ trait = "canopy_cover",
257+ date = "~2018 May",
258+ limit = "none")
276259
277260trait_canopy_cover_day <- trait_canopy_cover %>%
278261 mutate(day = as.Date(raw_date))
@@ -283,15 +266,14 @@ We now need to add the height data to the data set to plot.
283266We then determine the average canopy cover across the site for the day that the sensor data were collected.
284267The relationship between our greenness metric and average canopy cover are plotted.
285268
286- ``` {r plot_sensor_trait}
269+ ``` {r plot_sensor_trait, warning=FALSE }
287270trait_canopy_cover_daily <- trait_canopy_cover_day %>%
288271 filter(day %in% greenness_df$day) %>%
289272 group_by(day) %>%
290273 summarise(mean_canopy_cover = mean(mean),
291274 sd_canopy_cover = sd(mean))
292275sensor_trait_df <- left_join(trait_canopy_cover_daily, greenness_df, by = "day")
276+
293277ggplot(sensor_trait_df, aes(x = mean_canopy_cover, y = greeness)) +
294278 geom_point()
295279```
296-
297-
0 commit comments