Customizing Downloaded Image Names in OpenEO: Any Options?

Hello everyone,

I’m currently working with OpenEO and I’m curious if there’s a method to specify the names of the images downloaded using the openeo::download_results function. It would greatly help with organizing my data. Any insights or tips on how to achieve this would be much appreciated.

Thank you!

Hi,
you could try using the ‘filename_prefix’ format option:

It at least gives you some control over filenaming, and also ensures that stac metadata immediately has the right name.

Please let us know if this is not what you were looking for.

Thank you for your prompt response. I forgot to mention that I’m using OpenEO in R. I couldn’t find the filename_prefix method. Is it suitable for R users as well?

Hi,
I’ve tested the new feature in the R-Client - it’s working.
Here’s a piece of code you can run to test it:

library(openeo)
library(sf)

host = "https://openeo.cloud"
openeo::connect(host = host)
openeo::login()

p = openeo::processes()
bbox = st_bbox(c(xmin = 16.1, xmax = 16.2, ymax = 48.2, ymin = 48.1), crs = st_crs(4326))
temp = list("2018-04-01", "2018-04-15")
bnds = list("B08","B04")

data = p$load_collection(id = "SENTINEL2_L2A", 
                         spatial_extent = bbox, 
                         temporal_extent = temp, 
                         bands = bnds)
spectral_reduce = p$reduce_dimension(data = data, 
                                     dimension = "bands", 
                                     reducer = function(data,context) {
  B08 = data[1]
  B04 = data[2]
  return((B08-B04)/(B08+B04))
})

temporal_reduce = p$reduce_dimension(data=spectral_reduce, 
                                     dimension = "t", 
                                     reducer = function(x,y){
  p$min(x)
})

result = p$save_result(data=temporal_reduce, 
                       format = "GTiff", 
                       options = list(filename_prefix="TEST"))


job_id = openeo::create_job(graph=result, title="ndvi_min_fp4", format="GTiff")
openeo::start_job(job_id)
openeo::describe_job(job_id)
openeo::list_results(job_id)
download_results(job = job_id, folder = ".")

The output I get is:

> res = openeo::list_results(job_id)
> res$assets$TEST.tif$title
[1] "TEST.tif"

I hope that’s what you’re looking for.

@jeroen.dries, that’s a nice feature you have added!

Thanks a bunch for the helpful solution; it really sorted out my issue!

However, I’ve got another question. I’m trying to download images within a date range, and I want the file names to be in the format “prefix_i_decide_YYYY-MM-DD”. The problem is, due to Zulu time, they end up with a “Z” at the end, like “prefix_i_decide_YYYY-MM-DDZ”. Is there any way to automatically handle this in the openEO platform? Any insights would be much appreciated. Thanks in advance!

Snippet of the code:

# I've tried as.date() as well and it didn't work 
from_date <- "2018-12-01"
to_date <- "2019-03-30"

cube = p$load_collection(id = collections$SENTINEL2_L2A,
                         spatial_extent = bbox_t,
                         temporal_extent = c(from_date, to_date),
                         bands = c('B01', 'B02', 'B03', 'B04', 'B05', 'B06', 'B07', 'B08', 'B8A', 'B09', 'B11', 'B12'),
                         properties = list(
                         "eo:cloud_cover" = function(x) x <= 10))

cube_s2_vi = p$reduce_dimension(data = cube, reducer = calculate_vi_, dimension = "bands")

result = p$save_result(data = cube_s2_vi, format = formats$output$GTiff, options = list(filename_prefix=veg_index))

job_1 = openeo::create_job(graph = result, title = "check prefix")
openeo::start_job(job = job_1, log = TRUE)

jobs_vi = openeo::list_results(job = job_1)

image