Skip to main content

I am having trouble with downloading the S2 L2A bands see below my request script. The request runs but it returns an empty image when I open it in ArcMap?


Your assistance is appreciated, I just removed the Bearer token.


curl -X POST https://services.sentinel-hub.com/api/v1/process \
-H 'Content-Type: multipart/form-data' \
-H 'Authorization: \
--form-string 'request={
"input": {
"bounds": {
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
387586.974469,
8098945.900398
],
[
387884.086646,
8097476.83939
],
[
389674.763248,
8097959.748413
],
[
389409.287272,
8099351.638973
],
[
387586.974469,
8098945.900398
]
]
]
},
"properties": {
"crs": "http://www.opengis.net/def/crs/EPSG/0/32737"
}
},
"data": [
{
"dataFilter": {
"timeRange": {
"from": "2023-06-16T00:00:00Z",
"to": "2023-06-16T23:59:59Z"
},
"mosaickingOrder": "mostRecent"
},
"type": "sentinel-2-l2a"
}
]
},
"output": {
"width": 104.12118271595553,
"height": 93.89618236811039,
"responses": [
{
"identifier": "default",
"format": {
"type": "image/tiff"
}
}
]
}
}' \
--form-string 'evalscript=//VERSION=3

function setup() {
return {
input: [
{
bands: ["B01","B04","B07","B09","B02","B05","B08","B11","B03","B06","B12","B8A"],
units: "REFLECTANCE",
}
],
output: [
{
id: "default",
bands: 12,
sampleType: "UINT16",
noDataValue: 0,
},
],
mosaicking: "SIMPLE",
};
}


function evaluatePixel(sample) {
let val = [sample.B01, sample.B02, sample.B03, sample.B04, sample.B05, sample.B06, sample.B07, sample.B08, sample.B8A, sample.B09, sample.B1972, sample.B12];
return val;
}

'

Hi Rickus,


Thanks for the question, for Sentinel-2 optical data, the relation between DN and REFLECTANCE (default unit) is: DN = 10000 * REFLECTANCE so in your evalscript you need to multiply each sample.[band] by 1000 to return the surface reflectance data in UINT16 format. For more info, I recommend reading this part of the docs.


Below is also the correct evalscript which will return an image for you!


//VERSION=3
function setup() {
return {
input: [
{
bands: ["B01","B04","B07","B09","B02","B05","B08","B11","B03","B06","B12","B8A"],
units: "REFLECTANCE",
}
],
output: [
{
id: "default",
bands: 12,
sampleType: "UINT16",
},
],
};
}


function evaluatePixel(sample) {
let val = [10000 * sample.B01, 10000 * sample.B02, 10000 * sample.B03, 10000 * sample.B04, 10000 * sample.B05, 10000 * sample.B06, 10000 * sample.B07, 10000 * sample.B08, 10000 * sample.B8A, 10000 * sample.B09, 10000 * sample.B11, 10000 * sample.B12];
return val;
}

Thanks William, that has solved the problem, appreciate the help.


This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.


Reply