-
Notifications
You must be signed in to change notification settings - Fork 3
Description
we have a mutate.tidyee
method. Currently it only really effects the vrt
. I've been running across the situation where it would be nice if the mutate could also set the property for each image in the imageCollection.... think it could be something simple like mutate(...,set_img_prop=T)
i've gotten the concept pretty close with the below. The result mutates the vrt
and then returns the imageCollection with image properties set. It's set so that however many columns are mutated to the vrt these will be added to the imageCollection via purrr::map
- problem is that if there are more than 1 columns mutated, each mapping iteration is returning an individual imageCollection with the property set and I am drawing a blank on the best way to join them. They should be joinable by "system:index" or "system:time_start", but i'd like to join them so that the properties merge, not the bands
mutate_new_idea <- function(.data,
...){
new_col_names <- .data$vrt |>
dplyr::transmute(...) |> colnames()
vrt <- .data$vrt |>
dplyr::mutate(...) |>
arrange(.data$time_start)
ee_ob <- .data$ee_ob$sort(prop = "system:time_start",opt_ascending = T)
ics<-new_col_names |>
purrr::map(~{
ee_new_prop <- ee$List(vrt[[.x]])
idx_list = ee$List$sequence(0,ee_new_prop$size()$subtract(1))
ic_list = ee_ob$toList(ee_ob$size())
ic_temp <- ee$ImageCollection(
idx_list$map(rgee::ee_utils_pyfunc(
function(idx){
img = ee$Image(ic_list$get(idx))
#create as string
idx_string = ee$String(ee_new_prop$get(idx))
img$set(.x, idx_string)
}))
)
return(ic_temp)
}
)