From 12ea7cb3eed7fae030bf2e7a4cb0a6c8b1326f74 Mon Sep 17 00:00:00 2001 From: Felipe Carlos Date: Thu, 16 Jan 2025 23:07:27 -0300 Subject: [PATCH 1/2] fix mosaic generation in windows --- R/api_mosaic.R | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/R/api_mosaic.R b/R/api_mosaic.R index 856ec4be..b8b196ba 100644 --- a/R/api_mosaic.R +++ b/R/api_mosaic.R @@ -173,6 +173,13 @@ tile = asset, band = .tile_bands(asset), version = version, output_dir = output_dir ) + # Create a temporary output file name + # (this is required as in Windows machines, GDAL can't read and write + # using the same file) + out_file_base <- .file_crop_name( + tile = asset, band = .tile_bands(asset), + version = paste0(version, "mosaic"), output_dir = output_dir + ) # Resume feature if (.raster_is_valid(out_file, output_dir = output_dir)) { .check_recovery(out_file) @@ -238,6 +245,8 @@ multicores = 1, overwrite = TRUE ) + # Move the generated file to use the correct name + file.rename(out_file_base, out_file) # Update asset metadata update_bbox <- if (.has(roi)) TRUE else FALSE asset <- .tile_from_file( From 44e610686a5e220929f2211772095ec89039160e Mon Sep 17 00:00:00 2001 From: Felipe Carlos Date: Thu, 16 Jan 2025 23:40:39 -0300 Subject: [PATCH 2/2] fix roi mosaic --- R/api_mosaic.R | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/R/api_mosaic.R b/R/api_mosaic.R index b8b196ba..85f77599 100644 --- a/R/api_mosaic.R +++ b/R/api_mosaic.R @@ -209,8 +209,8 @@ is_within <- .tile_within(asset, roi) if (is_within) { # Reproject tile for its crs - .gdal_reproject_image( - file = out_file, out_file = out_file, + out_file <- .gdal_reproject_image( + file = out_file, out_file = out_file_base, crs = .as_crs(.tile_crs(asset)), as_crs = .mosaic_crs(tile = asset, as_crs = crs), miss_value = .miss_value(band_conf), @@ -237,7 +237,7 @@ # Crop and reproject tile image out_file <- .gdal_crop_image( file = out_file, - out_file = out_file, + out_file = out_file_base, roi_file = roi, as_crs = .mosaic_crs(tile = asset, as_crs = crs), miss_value = .miss_value(band_conf),