knitr::opts_knit$set(base.dir = 'analysis/rmd/')
knitr::opts_chunk$set(fig.retina = 3, fig.align = 'center', fig.width = 6.93, 
                      fig.height = 6.13, out.width = "100%")
source(here::here("code/99-packages.R"))

loadd(records, aoi, cloud_mosaic)
records %<>% split(records[[2]]$beginposition)

# Unique dates
date_scenes =  
  records %>%
  map(~ dplyr::select(., beginposition)) %>%
  map(~ unique(.)) %>%
  map_chr(~ str_sub(., 1, 10))

# Scenes per mosaic/ date
count_scenes =
  records %>%
  map_dbl(~ nrow(.))

# Row number of mosaic
row_scenes =
  records %>%
  map(~ dplyr::select(., relativeorbitnumber)) %>%
  map(~ pull(.)) %>%
  map_chr(~ unique(.))

# Calculate area of aoi
aoi_area = st_area(aoi) %>%
  sum()

# Calculate cloud cover
cloud_scenes =
  cloud_mosaic %>%
  map(~ st_read(., quiet=TRUE)) %>%
  map(~ st_set_crs(., 25830)) %>%
  map(~ st_intersection(st_buffer(., 0), aoi)) %>%
  map(possibly(~ st_union(.), NA)) %>%
  map(possibly(~ st_area(.), NA)) %>%
  map_dbl(possibly(~ sum(.), NA)) %>%
  map_dbl(possibly(~ ./aoi_area, NA))

ext_scenes =
  records %>%
  map(~ dplyr::select(., footprint)) %>%
  map_depth(2, ~ st_as_sfc(.)) %>%
  map_depth(2, ~ st_set_crs(., 4326)) %>%
  map_depth(2, ~ st_transform(., 32630)) %>%
  set_names(date_scenes)
tibble(date = date_scenes, row = row_scenes, count = count_scenes, clouds = cloud_scenes) %>%
  saveRDS("scenes.rds")

2018-04-19 O% Check 2018-06-23 0% Check 2018-07-23 0% Check 2018-08-12 0% Check 2018-08-27 0% Check 2018-09-01 0% Check 2018-09-11 0% Check 2018-09-26 2% Check

mapView(ext_scenes[[56]]) + mapView(aoi)


pat-s/2019-feature-selection documentation built on Dec. 24, 2021, 8:40 a.m.