Scenes in preProcessScenes and updateOutputMetadata are missing dates

Hello
Im trying to retrieve a meta-data on scenes using the next request:

bbox=BBox('-53.44174990020377,-22.38538161005017,-53.43715803852127,-22.38024062362553', CRS.WGS84)
time_interval=('2021-02-01', '2021-03-01')
evalscript = """ //VERSION=3
function evaluatePixel() {}
function setup() {
    return {
        input: [{ bands:["dataMask", "CLM"]}],
        output: { bands: 0 },  
        mosaicking: "ORBIT",
    }
}
let col;
function preProcessScenes(collections){
    col = collections;
    return collections;
}
function updateOutputMetadata(scenes, inputMetadata, outputMetadata) {
    outputMetadata.userData = { 
        "scenes":scenes,
        "collections":col
    }
}"""

SentinelHubRequest(
    evalscript=evalscript,
    input_data=[
        SentinelHubRequest.input_data(data_collection=DataCollection.SENTINEL2_L1C, time_interval=time_interval)
    ],
    responses=[SentinelHubRequest.output_response('userdata', MimeType.JSON)],
    bbox=bbox,
    geometry=geometry,
    size = bbox_to_dimensions(bbox, resolution=60),
    config=config,
    data_folder='./data'
)

And here is what I’m receiving:

[{
'collections': {
    'scenes': [
        {'date': {}, '__idx': 0},
        {'date': {}, '__idx': 1},
        {'date': {}, '__idx': 2},
        {'date': {}, '__idx': 3},
        {'date': {}, '__idx': 4},
        {'date': {}, '__idx': 5}],
       'from': {},
       'to': {}
},
'scenes': [
       {'date': {}, 'bandBuffers': [], '__idx': 0},
       {'date': {}, 'bandBuffers': [], '__idx': 1},
       {'date': {}, 'bandBuffers': [], '__idx': 2},
       {'date': {}, 'bandBuffers': [], '__idx': 3},
       {'date': {}, 'bandBuffers': [], '__idx': 4},
       {'date': {}, 'bandBuffers': [], '__idx': 5}
]
}]

The “scenes” are missing the dates in both - preProcessScenes and updateOutputMetadata functions…
The question is - why are all of the dates missing?

I think that you are getting blank responses because the scenes and col variables are javascript objects. I converted the objects to strings in your example and got a response:

function updateOutputMetadata(scenes, inputMetadata, outputMetadata) {
    outputMetadata.userData = { 
        "scenes":JSON.stringify(scenes),
        "collections":JSON.stringify(col)
    }

@batic can you confirm?

1 Like

Yes, JavaScript Objects should be stringified.