@@ -128,14 +128,7 @@ makeELFs <- function(x, desiredBuffer = 20000,
128128
129129 ELFs <- bufferOut(spatRasSeg = out3 , mask = hf ,
130130 desiredBuffer = desiredBuffer ,
131- useCache = useCache ) | >
132- reproducible :: Cache(omitArgs = c(" spatRasSeg" , " mask" ),
133- .cacheExtra = list (x = digNFP ,
134- attr(out2 , " tags" )# ,
135- # attr(out, "tags")
136- ),
137- useCache = useCache )
138-
131+ useCache = useCache )
139132 # ELFs <- bufferOut(spatRasSeg = out3, mask = out$rasWhole[[1]],
140133 # desiredBuffer = desiredBuffer,
141134 # useCache = useCache) |>
@@ -165,7 +158,17 @@ makeELFs <- function(x, desiredBuffer = 20000,
165158 ELFs <- Reduce(rbind , allVec )
166159
167160 }
168-
161+
162+ # ELFs2 <- Map(e = ELFs, function(e) {
163+ # ff <- Filenames(e)
164+ # nzff <- nzchar(ff)
165+ # if (any(nzff)) {
166+ # whnzff <- which(nzff)
167+ # e[whnzff] <- Map(r = e[whnzff], function(r) {r[] <- terra::values(r, mat = FALSE); r})
168+ # }
169+ # e
170+ # })
171+
169172 ELFs
170173}
171174
@@ -300,21 +303,20 @@ bufferOut <- function(v, spatRasSeg, spatRas, mask, field = "FRU", desiredBuffer
300303 }
301304
302305 ll <- moveSliversToOtherELFs(lostPixels , lp , ca , i , r )
303- ll3 <- ll
306+ # ll3 <- ll
304307 destinationPath <- unique(dirname(Filenames(spatRasSeg )))
305308 ELFpath <- file.path(destinationPath , " ELFs_final" )
306309 unlink(ELFpath , recursive = TRUE )
307310 dir.create(ELFpath , recursive = TRUE , showWarnings = FALSE )
308311 message(" Writing ELF rasters to disk" )
309- for ( i in seq_along (ll )) {
310- for ( j in seq_along( i ) ) {
311- fn <- file.path(ELFpath , paste0(names( ll [[ i ]][[ j ]]) , " .tif" ))
312+ rr <- Map( out = ll , namOut = names (ll ), function ( out , namOut ) {
313+ Map( inner = out , nam = names( out ), function ( inner , nam ) {
314+ fn <- file.path(ELFpath , paste0(namOut , " _ " , nam , " .tif" ))
312315 unlink(fn )
313- ll [[i ]][[j ]] <- terra :: writeRaster(ll [[i ]][[j ]], filename = fn , overwrite = TRUE )
314- }
315- }
316-
317- list (rasCentered = ll $ r , rasWhole = ll $ ca )
316+ terra :: writeRaster(inner , filename = fn , overwrite = TRUE )
317+ })
318+ })
319+ list (rasCentered = rr $ r , rasWhole = rr $ ca )
318320}
319321
320322segregateKeepNames <- function (ecopR , omitClasses , classes = NULL ) {
0 commit comments