Skip to contents

Use

Get Lakes

Lakes Berlin

library(magrittr)

url <- "https://fbinter.stadt-berlin.de/fb/atom/Gewaesserkarte/Gewaesserkarte.zip"
tfile <- basename(url)

download.file(url, destfile = basename(url))

unzip(zipfile = tfile,
      exdir = "lakes_berlin")

lakes_berlin <- sf::read_sf("lakes_berlin/Gewaesser_Berlin_Flaechen.shp",
                                  options = "ENCODING=WINDOWS-1252") %>% 
  dplyr::mutate(area = sf::st_area(.)) %>%
  dplyr::filter(stringr::str_starts(GEWART, pattern = "Stehendes"))

Lakes Brandenburg

archive::archive_extract("https://data.geobasis-bb.de/geofachdaten/Wasser/Hydrologie/seen25.zip", 
                         dir = "lakes_bb")
lakes_bb <- sf::read_sf("lakes_bb/Seen25_20211105/seen25.shp")

csv_path <- system.file("extdata/seen25_selected.csv", package = "kwb.satellite")

lakes_bb_selected <- lakes_bb %>%
  dplyr::inner_join(readr::read_csv(csv_path, col_types = "c"), by = "SEE_KZ")


shp_path <- system.file("extdata/brandenburger_see_collection/seen25_wgs84_selection_centroid3.shp", package = "kwb.satellite")

lakes_bb_selected_points <- sf::read_sf(shp_path) %>% 
  dplyr::inner_join(lakes_bb_selected[, c("SEE_KZ", "JP_ID")] %>% 
                      dplyr::rename(geometry_polygon = geometry) %>% 
                      tibble::as_tibble() , by = "JP_ID")

Get Satellite Data

openeo_con <- openeo::connect(host = "https://openeo.dataspace.copernicus.eu")
openeo::login(openeo_con)

collection_id <- "SENTINEL2_L2A"

lakes_bb_selected_polygon <- lapply(seq_len(nrow(lakes_bb_selected)), function(i) {
  kwb.satellite::openeo_get_data(lakes = lakes_bb_selected[i,],
                                 collection_id = collection_id)
  })

job_ids <- sapply(seq_len(nrow(lakes_bb_selected)),
                  function(i) lakes_bb_selected_polygon[[i]]$job$id)

kwb.satellite::openeo_start_max_jobs(job_ids = job_ids)

jobs_finished <- tibble::as_tibble(openeo::list_jobs()) %>%
  dplyr::filter(status == "finished") %>%
  dplyr::arrange(dplyr::desc(updated))

nrow(jobs_finished)

jobs_meta <- lapply(jobs_finished$id, kwb.satellite::openeo_get_job_metadata) %>%
  dplyr::bind_rows()

### estimate execution time in days
n_lakes <- nrow(lakes_bb_selected)
n_jobs_parallel <- 2
mean(jobs_meta$usage.duration.value)*n_lakes/n_jobs_parallel/(3600*24)

### estimate execution cost credits
sum(jobs_meta$costs)*n_lakes/nrow(jobs_meta)

tdir <- fs::path_abs("./vignettes/openeo/lakes_bb_selected_polygon/")
fs::dir_create(tdir)

jobs_results <- lapply(jobs_finished$id, function(id) {
                       kwb.satellite::openeo_download_results(job_id = id,
                                                              tdir = tdir)
  })


metadata_bands <- kwb.satellite::openeo_get_bands_meta(collection_id)


readr::write_csv(metadata_bands,
                 file = file.path(fs::path_abs("./vignettes/openeo/"),
                               sprintf("%s_metadata_bands.csv",
                                       collection_id)))

Info

Session Info

sessioninfo::session_info() %>%
  details::details(open = TRUE)


[1m
[36m─ Session info ───────────────────────────────────────────────────────────────
[39m
[22m
 
[3m
[90msetting 
[39m
[23m 
[3m
[90mvalue
[39m
[23m
 version  R version 4.4.0 (2024-04-24 ucrt)
 os       Windows Server 2022 x64 (build 20348)
 system   x86_64, mingw32
 ui       RTerm
 language en
 collate  English_United States.utf8
 ctype    English_United States.utf8
 tz       UTC
 date     2024-05-30
 pandoc   3.1.11 @ C:/HOSTED~1/windows/pandoc/31F387~1.11/x64/PANDOC~1.11/ (via rmarkdown)


[1m
[36m─ Packages ───────────────────────────────────────────────────────────────────
[39m
[22m
 
[3m
[90m!
[39m
[23m 
[3m
[90mpackage    
[39m
[23m 
[3m
[90m*
[39m
[23m 
[3m
[90mversion
[39m
[23m 
[3m
[90mdate (UTC)
[39m
[23m 
[3m
[90mlib
[39m
[23m 
[3m
[90msource
[39m
[23m
 
[37m
[41mD
[49m
[39m archive       1.1.8   
[90m2024-04-28
[39m 
[90m[1]
[39m 
[90mCRAN (R 4.4.0)
[39m
   bit           4.0.5   
[90m2022-11-15
[39m 
[90m[1]
[39m 
[90mCRAN (R 4.4.0)
[39m
   bit64         4.0.5   
[90m2020-08-30
[39m 
[90m[1]
[39m 
[90mCRAN (R 4.4.0)
[39m
   bslib         0.7.0   
[90m2024-03-29
[39m 
[90m[1]
[39m 
[90mCRAN (R 4.4.0)
[39m
   cachem        1.1.0   
[90m2024-05-16
[39m 
[90m[1]
[39m 
[90mCRAN (R 4.4.0)
[39m
   class         7.3-22  
[90m2023-05-03
[39m 
[90m[2]
[39m 
[90mCRAN (R 4.4.0)
[39m
   classInt      0.4-10  
[90m2023-09-05
[39m 
[90m[1]
[39m 
[90mCRAN (R 4.4.0)
[39m
   cli           3.6.2   
[90m2023-12-11
[39m 
[90m[1]
[39m 
[90mCRAN (R 4.4.0)
[39m
   clipr         0.8.0   
[90m2022-02-22
[39m 
[90m[1]
[39m 
[90mCRAN (R 4.4.0)
[39m
   crayon        1.5.2   
[90m2022-09-29
[39m 
[90m[1]
[39m 
[90mCRAN (R 4.4.0)
[39m
   DBI           1.2.2   
[90m2024-02-16
[39m 
[90m[1]
[39m 
[90mCRAN (R 4.4.0)
[39m
   desc          1.4.3   
[90m2023-12-10
[39m 
[90m[1]
[39m 
[90mCRAN (R 4.4.0)
[39m
   details       0.3.0   
[90m2022-03-27
[39m 
[90m[1]
[39m 
[90mCRAN (R 4.4.0)
[39m
   digest        0.6.35  
[90m2024-03-11
[39m 
[90m[1]
[39m 
[90mCRAN (R 4.4.0)
[39m
   dplyr         1.1.4   
[90m2023-11-17
[39m 
[90m[1]
[39m 
[90mCRAN (R 4.4.0)
[39m
   e1071         1.7-14  
[90m2023-12-06
[39m 
[90m[1]
[39m 
[90mCRAN (R 4.4.0)
[39m
   evaluate      0.23    
[90m2023-11-01
[39m 
[90m[1]
[39m 
[90mCRAN (R 4.4.0)
[39m
   fansi         1.0.6   
[90m2023-12-08
[39m 
[90m[1]
[39m 
[90mCRAN (R 4.4.0)
[39m
   fastmap       1.2.0   
[90m2024-05-15
[39m 
[90m[1]
[39m 
[90mCRAN (R 4.4.0)
[39m
   fs            1.6.4   
[90m2024-04-25
[39m 
[90m[1]
[39m 
[90mCRAN (R 4.4.0)
[39m
   generics      0.1.3   
[90m2022-07-05
[39m 
[90m[1]
[39m 
[90mCRAN (R 4.4.0)
[39m
   glue          1.7.0   
[90m2024-01-09
[39m 
[90m[1]
[39m 
[90mCRAN (R 4.4.0)
[39m
   hms           1.1.3   
[90m2023-03-21
[39m 
[90m[1]
[39m 
[90mCRAN (R 4.4.0)
[39m
   htmltools     0.5.8.1 
[90m2024-04-04
[39m 
[90m[1]
[39m 
[90mCRAN (R 4.4.0)
[39m
   htmlwidgets   1.6.4   
[90m2023-12-06
[39m 
[90m[1]
[39m 
[90mCRAN (R 4.4.0)
[39m
   httr          1.4.7   
[90m2023-08-15
[39m 
[90m[1]
[39m 
[90mCRAN (R 4.4.0)
[39m
   jquerylib     0.1.4   
[90m2021-04-26
[39m 
[90m[1]
[39m 
[90mCRAN (R 4.4.0)
[39m
   jsonlite      1.8.8   
[90m2023-12-04
[39m 
[90m[1]
[39m 
[90mCRAN (R 4.4.0)
[39m
   KernSmooth    2.23-22 
[90m2023-07-10
[39m 
[90m[2]
[39m 
[90mCRAN (R 4.4.0)
[39m
   knitr         1.47    
[90m2024-05-29
[39m 
[90m[1]
[39m 
[90mCRAN (R 4.4.0)
[39m
   lifecycle     1.0.4   
[90m2023-11-07
[39m 
[90m[1]
[39m 
[90mCRAN (R 4.4.0)
[39m
   magrittr    * 2.0.3   
[90m2022-03-30
[39m 
[90m[1]
[39m 
[90mCRAN (R 4.4.0)
[39m
   memoise       2.0.1   
[90m2021-11-26
[39m 
[90m[1]
[39m 
[90mCRAN (R 4.4.0)
[39m
   pillar        1.9.0   
[90m2023-03-22
[39m 
[90m[1]
[39m 
[90mCRAN (R 4.4.0)
[39m
   pkgconfig     2.0.3   
[90m2019-09-22
[39m 
[90m[1]
[39m 
[90mCRAN (R 4.4.0)
[39m
   pkgdown       2.0.9   
[90m2024-04-18
[39m 
[90m[1]
[39m 
[90mCRAN (R 4.4.0)
[39m
   png           0.1-8   
[90m2022-11-29
[39m 
[90m[1]
[39m 
[90mCRAN (R 4.4.0)
[39m
   proxy         0.4-27  
[90m2022-06-09
[39m 
[90m[1]
[39m 
[90mCRAN (R 4.4.0)
[39m
   purrr         1.0.2   
[90m2023-08-10
[39m 
[90m[1]
[39m 
[90mCRAN (R 4.4.0)
[39m
   R6            2.5.1   
[90m2021-08-19
[39m 
[90m[1]
[39m 
[90mCRAN (R 4.4.0)
[39m
   ragg          1.3.0   
[90m2024-03-13
[39m 
[90m[1]
[39m 
[90mCRAN (R 4.4.0)
[39m
   Rcpp          1.0.12  
[90m2024-01-09
[39m 
[90m[1]
[39m 
[90mCRAN (R 4.4.0)
[39m
   readr         2.1.5   
[90m2024-01-10
[39m 
[90m[1]
[39m 
[90mCRAN (R 4.4.0)
[39m
   rlang         1.1.3   
[90m2024-01-10
[39m 
[90m[1]
[39m 
[90mCRAN (R 4.4.0)
[39m
   rmarkdown     2.27    
[90m2024-05-17
[39m 
[90m[1]
[39m 
[90mCRAN (R 4.4.0)
[39m
   sass          0.4.9   
[90m2024-03-15
[39m 
[90m[1]
[39m 
[90mCRAN (R 4.4.0)
[39m
   sessioninfo   1.2.2   
[90m2021-12-06
[39m 
[90m[1]
[39m 
[90mCRAN (R 4.4.0)
[39m
   sf            1.0-16  
[90m2024-03-24
[39m 
[90m[1]
[39m 
[90mCRAN (R 4.4.0)
[39m
   stringi       1.8.4   
[90m2024-05-06
[39m 
[90m[1]
[39m 
[90mCRAN (R 4.4.0)
[39m
   stringr       1.5.1   
[90m2023-11-14
[39m 
[90m[1]
[39m 
[90mCRAN (R 4.4.0)
[39m
   systemfonts   1.0.6   
[90m2024-03-07
[39m 
[90m[1]
[39m 
[90mCRAN (R 4.4.0)
[39m
   textshaping   0.3.7   
[90m2023-10-09
[39m 
[90m[1]
[39m 
[90mCRAN (R 4.4.0)
[39m
   tibble        3.2.1   
[90m2023-03-20
[39m 
[90m[1]
[39m 
[90mCRAN (R 4.4.0)
[39m
   tidyselect    1.2.1   
[90m2024-03-11
[39m 
[90m[1]
[39m 
[90mCRAN (R 4.4.0)
[39m
   tzdb          0.4.0   
[90m2023-05-12
[39m 
[90m[1]
[39m 
[90mCRAN (R 4.4.0)
[39m
   units         0.8-5   
[90m2023-11-28
[39m 
[90m[1]
[39m 
[90mCRAN (R 4.4.0)
[39m
   utf8          1.2.4   
[90m2023-10-22
[39m 
[90m[1]
[39m 
[90mCRAN (R 4.4.0)
[39m
   vctrs         0.6.5   
[90m2023-12-01
[39m 
[90m[1]
[39m 
[90mCRAN (R 4.4.0)
[39m
   vroom         1.6.5   
[90m2023-12-05
[39m 
[90m[1]
[39m 
[90mCRAN (R 4.4.0)
[39m
   withr         3.0.0   
[90m2024-01-16
[39m 
[90m[1]
[39m 
[90mCRAN (R 4.4.0)
[39m
   xfun          0.44    
[90m2024-05-15
[39m 
[90m[1]
[39m 
[90mCRAN (R 4.4.0)
[39m
   xml2          1.3.6   
[90m2023-12-04
[39m 
[90m[1]
[39m 
[90mCRAN (R 4.4.0)
[39m
   yaml          2.3.8   
[90m2023-12-11
[39m 
[90m[1]
[39m 
[90mCRAN (R 4.4.0)
[39m


[90m [1] D:/a/_temp/Library
[39m

[90m [2] C:/R/library
[39m

 
[41m
[37mD
[39m
[49m ── DLL MD5 mismatch, broken installation.


[1m
[36m──────────────────────────────────────────────────────────────────────────────
[39m
[22m