|
406 | 406 | class(samples) <- c("sits", class(samples))
|
407 | 407 | return(samples)
|
408 | 408 | }
|
409 |
| - |
410 |
| -#' @title Split tile bands for extraction of values inside segments |
411 |
| -#' @name .segments_split_tile_bands |
412 |
| -#' @keywords internal |
413 |
| -#' @noRd |
414 |
| -#' @param tile input tile |
415 |
| -#' @param bands bands where data will be extracted |
416 |
| -#' |
417 |
| -#' @return tibble with band-files pairs |
418 |
| -#' |
419 |
| -.segments_split_tile_bands <- function(tile, bands) { |
420 |
| - tile_bands <- purrr::map(bands, function(band) { |
421 |
| - band_files <- .fi_filter_bands(.fi(tile), band)[["path"]] |
422 |
| - tibble::tibble( |
423 |
| - band = band, |
424 |
| - files = list(band_files), |
425 |
| - segs_path = .segments_path(tile), |
426 |
| - params = list(.tile_band_conf(tile, band)) |
427 |
| - ) |
428 |
| - }) |
429 |
| - tile_bands <- dplyr::bind_rows(tile_bands) |
430 |
| - return(tile_bands) |
431 |
| -} |
432 |
| -#' @title Split tile bands for extraction of values inside segments |
433 |
| -#' @name .segments_split_tile_bands_list |
434 |
| -#' @keywords internal |
435 |
| -#' @noRd |
436 |
| -#' @param tile input tile |
437 |
| -#' @param bands bands where data will be extracted |
438 |
| -#' @param segments large set of segments |
439 |
| -#' @param n_iterations number of parts to break the segments |
440 |
| -#' @param output_dir directory to write the segments |
441 |
| -#' @return list of tibbles with band-files pairs |
442 |
| -#' |
443 |
| -.segments_split_tile_bands_list <- function(tile, |
444 |
| - bands, |
445 |
| - segments, |
446 |
| - n_iterations, |
447 |
| - output_dir) { |
448 |
| - |
449 |
| - segments[["group"]] <- rep( |
450 |
| - seq_len(n_iterations), each = ceiling(nrow(segments) / n_iterations) |
451 |
| - )[seq_len(nrow(segments))] |
452 |
| - |
453 |
| - segments_lst <- dplyr::group_split( |
454 |
| - dplyr::group_by(segments, .data[["group"]]) |
455 |
| - ) |
456 |
| - segment_files <- purrr::map_chr(segments_lst, function(seg_part) { |
457 |
| - # Block file name |
458 |
| - hash_bundle <- digest::digest(seg_part, algo = "md5") |
459 |
| - seg_file <- .file_path( |
460 |
| - paste0(hash_bundle, "_segments"), |
461 |
| - ext = "gpkg", |
462 |
| - output_dir = output_dir |
463 |
| - ) |
464 |
| - .vector_write_vec(seg_part, seg_file) |
465 |
| - return(seg_file) |
466 |
| - }) |
467 |
| - seg_tile_band_lst <- purrr::map(segment_files, function(seg_file) { |
468 |
| - tile_bands <- purrr::map(bands, function(band) { |
469 |
| - band_files <- .fi_filter_bands(.fi(tile), band)[["path"]] |
470 |
| - tibble::tibble( |
471 |
| - band = band, |
472 |
| - files = list(band_files), |
473 |
| - segs_path = seg_file, |
474 |
| - params = list(.tile_band_conf(tile, band)) |
475 |
| - ) |
476 |
| - }) |
477 |
| - seg_tile_band <- dplyr::bind_rows(tile_bands) |
478 |
| - return(seg_tile_band) |
479 |
| - }) |
480 |
| - return(seg_tile_band_lst) |
481 |
| -} |
0 commit comments