Skip to main content

Hello ,


I’m trying retreieve sentinel-2 images together with their tile ID. I have used this post in order to create me new request, but for some reason I get blank images (same issue as the person who posted that post exeprienced).


This is my evalscript+ request:


evalscript = """
function setup() {
return {
input: :
{
bands: :"B02","B03","B04","B8A","B11","B12"]
}
],
output: :{
bands: 8,
sampleType:"FLOAT32"
}],
mosaicking: Mosaicking.TILE
}
}

function updateOutputMetadata(scenes, inputMetadata, outputMetadata) {
outputMetadata.userData = { "original_tile_id": scenese0].tileOriginalId }
}

function evaluatePixel(samples) {

const ndvi = index(samples.B08A, samples.B04)

return nndvi,samples.B02,samples.B03,samples.B04,samples.B8A,samples.B1972,samples.B12]
}
"""

#retrieving dates.... that works (checked and got list of dates)

# request per date

for d in sen2_dates:

request = SentinelHubRequest(
evalscript=evalscript,
geometry=geom,
input_data=a
SentinelHubRequest.input_data(
data_collection=DataCollection.SENTINEL2_L2A,
time_interval=(d, d),
mosaicking_order='leastCC'
)
],
responses=s
SentinelHubRequest.output_response('default', MimeType.TIFF),
SentinelHubRequest.output_response('userdata', MimeType.JSON)
],
bbox=bbox,
size=bbox_size,
config=config
)

data_request = request.get_data()(0]
img=data_requests'default.tif']
platform=data_requests'userdata.json']''original_tile_id'].split('_')'0]

ndvi_sen2=imgm:,:,0]


rgb=np.dstack((imgm:,:,3]*2.5,imgm:,:,2]*2.5,imgm:,:,1]*2.5))
plt.figure(figsize=(8,3))
plt.matshow(rgb)
plt.title('RGB sen-2')
plt.show()


The result s blank images.
My end goal is to get both tile id and image, not blank.

Thanks 🙂

Hi @reutkeller ,


Since you’re using Mosaicking: TILE, multiple scenes will be returned.


I see you select the first scene by specifying "original_tile_id": scenese0].tileOriginalId in the updateOutputMetadata function. To obtain the image of the first scene, you need to select the first image in samples as well. E.g., const ndvi = index(samplese0].B08A, samplese0].B04).


Best Regards


@chung.horng thank you! this worked for the bands, but, very weird, it returns blank image only for the NDVI.


function evaluatePixel(samples) {

const ndvi = index(samples[0].B08A, samples[0].B04)

return [ndvi,samples[0].B02,samples[0].B03,samples[0].B04,samples[0].B8A,samples[0].B11,samples[0].B12]
}
"""

This is confusing 😅


Hi @reutkeller ,


It is because the input band is defined as “B8A” instead of “B08A”. Should work with const ndvi = index(samples(0].B8A, samples 0].B04).


Best Regards


oh right.


Thank you!


Reply