Skip to content

Commit d01daf3

Browse files
Merge pull request #1484 from OldLipe/feat/reclassify-tile
Add support for multiple tiles in `sits_reclassify()`
2 parents 22167ef + 98afa49 commit d01daf3

2 files changed

Lines changed: 11 additions & 4 deletions

File tree

R/api_gdal.R

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,11 @@
142142
file <- file[[1L]]
143143
# Convert to gdal data type
144144
data_type <- .gdal_data_type[[data_type]]
145+
co <- .conf("gdal_presets", "image", "co")
146+
if (data_type == "Float64") {
147+
co <- setdiff(co, c("COMPRESS=LZW", "PREDICTOR=2"))
148+
co <- c("COMPRESS=ZSTD", "PREDICTOR=3", co)
149+
}
145150
# Output file
146151
file <- .try(
147152
{
@@ -165,7 +170,7 @@
165170
.xmin(bbox), .ymax(bbox), .xmax(bbox), .ymin(bbox)
166171
),
167172
"-a_nodata" = miss_value,
168-
"-co" = .conf("gdal_presets", "image", "co")
173+
"-co" = co
169174
),
170175
quiet = TRUE
171176
)

R/api_reclassify.R

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,18 +84,20 @@
8484
nlayers = 1L, miss_value = .miss_value(band_conf),
8585
data_type = .data_type(band_conf)
8686
)
87-
# Copy values from mask cube into mask template
87+
# Get mask files
88+
paths <- purrr::map_chr(mask[["file_info"]], .fi_paths)
89+
# Copy values into template block
8890
.gdal_merge_into(
8991
file = mask_block_file,
90-
base_files = .fi_paths(.fi(mask)), multicores = 1L
92+
base_files = paths, multicores = 1L
9193
)
9294
# Build a new tile for mask based on template
9395
mask_tile <- .tile_derived_from_file(
9496
file = mask_block_file,
9597
band = "class",
9698
base_tile = .tile(mask),
9799
derived_class = "class_cube",
98-
update_bbox = FALSE
100+
update_bbox = TRUE
99101
)
100102
# Read and preprocess values
101103
values <- .tile_read_block(

0 commit comments

Comments
 (0)