Skip to content

Commit

Permalink
🚀 :bang:
Browse files Browse the repository at this point in the history
  • Loading branch information
cboettig committed Mar 8, 2024
1 parent cd692c9 commit e429759
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 26 deletions.
27 changes: 3 additions & 24 deletions R/create_target_file.R
Original file line number Diff line number Diff line change
Expand Up @@ -53,36 +53,15 @@ create_target_file <- function(
# needed to write geotif to VSI
Sys.setenv("CPL_VSIL_USE_TEMP_FILE_FOR_RANDOM_WRITE"="YES")

out <- glue::glue("{dir}/{dt}/{var}/{site_id}/lai_recovery-target-{date}.tif")

#file out
fileOut <- glue::glue("{dir}/lai_recovery-target-{date}.tif")

# doesn't take VSI yet; so convert to stars first instead:
# write_tif(target, dir, "lai_recovery_target_")

target %>%
stars::st_as_stars() %>%
stars::write_stars(fileOut)
stars::write_stars(out)
}


#Write output
if (!is.null(bucket)){
#Minioclient alias information
minioclient::mc_alias_set(alias = "efi",
endpoint = "data.ecoforecast.org",
access_key = Sys.getenv("AWS_ACCESS_KEY_ID"),
secret_key = Sys.getenv("AWS_SECRET_ACCESS_KEY"))


#Bucket output
tif <- basename(fileOut)
out <- glue::glue("{bucket}/{dt}/{var}/{site_id}/{tif}")

#Copy target file from output directory to target bucket
minioclient::mc_cp(fileOut, out)
}#End if bucket available

#return target
invisible(target)
invisible(out)
}
4 changes: 2 additions & 2 deletions targets/spatial_targets.R
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ readRenviron(".Renviron")
target <- create_target_file(cuberast = raster_cube,
site_id = site_id,
date = as.character(start_date),
dir = tempdir(),
bucket = "efi/spat4cast-targets",
dir = "/vsis3/spat4cast-targets",
bucket = NULL,
mask = fire_box$maskLayer,
dt = dt,
var = "LAI_modis")
Expand Down

0 comments on commit e429759

Please sign in to comment.