Issue for bounding box to download NDVI for Sentinel 2 S2L1C

Respected Sir/Ma’am,
I am trying to get NDVI for my study area but the issue is the bounding box is too large for the data. Is there a way I can get data for the whole area? My area is about 672472.44 km2. Further attesting the image and script:
curl -X POST https://services.sentinel-hub.com/api/v1/process
-H ‘Content-Type: application/json’
-H ‘Authorization: Bearer my-token’
-d ‘{
“input”: {
“bounds”: {
“geometry”: {
“type”: “Polygon”,
“coordinates”: [
[
[
-155.63424,
67.028205
],
[
-160.262603,
66.237243
],
[
-160.40941,
64.221812
],
[
-161.20485,
63.093609
],
[
-161.663525,
61.498408
],
[
-140.734505,
61.705222
],
[
-140.431903,
68.596849
],
[
-155.806529,
68.108271
],
[
-155.63424,
67.028205
]
]
]
},
“properties”: {
“crs”: “http://www.opengis.net/def/crs/EPSG/0/4326
}
},
“data”: [
{
“type”: “S2L1C”,
“dataFilter”: {
“timeRange”: {
“from”: “2018-04-09T00:00:00Z”,
“to”: “2018-04-09T23:59:59Z”
},
“maxCloudCoverage”: 4
}
}
]
},
“output”: {
“width”: 512,
“height”: 360.322,
“responses”: [
{
“identifier”: “default”,
“format”: {
“type”: “image/tiff”
}
}
]
},
“evalscript”: “//VERSION=3\nfunction setup() {\n return {\n input: [“B04”, “B08”],\n output: { bands: 1, sampleType: “UINT16” }\n };\n}\n\nfunction evaluatePixel(sample) {\nlet ndvi = index(sample.B08, sample.B04);\nreturn [10000 * ndvi + 10000];\n}”
}’

EVALSCRIPT:
//VERSION=3
function setup() {
return {
input: [“B04”, “B08”],
output: { bands: 1, sampleType: “UINT16” }
};
}

function evaluatePixel(sample) {
let ndvi = index(sample.B08, sample.B04);
return [10000 * ndvi + 10000];
}

Another issue is after going through this query NDVI values from SentinelHub different from the ones calculates in Qgis
these are the values I was looking for in the data I needed rather than values between 0-255. But as suggested ndvi_float = (ndvi - 10000.)/10000. has to be followed after downloading the image. I will be using daily data meaning I have to repeat this process for every image. Is there a way of directly downloading values within the range [-1 to1 ] for NDVI.
If I try to download Sentinel 3 SLSTR L1B data using the area of my study as kml file I can download it but the resolution is 500m thus I was trying for Sentinel 2.

Thank you in advance and any help will be highly appreciated.

Hi,

If you want the values without having to do the conversion step for NDVI, you can change the sampleType to “FLOAT32” and return [ndvi]; in your evaluatePixel function.

To work with large areas such as yours but request data at higher resolution, you have two options:

Maxim

okay, sir will try that.

Respected Sir/Ma’am,
I am trying to download band S2 for NDVI from the SLSTR data source. I want the pixel values in meters what I tried so far I turned the resolution in meters slider on highlighting green light, I mentioned my resolution to be 500*500 as per the pixel size of the band and keeping the EPSG code to 3857 for values in meters,


2

But after downloading a single day image the pixel size shows twice the value of resolution as I mentioned, but on actually manually measuring the pixel using ArcPRO it shows values below 500 for both x and y axis not exact 500. 3

I tried turning off the resolution in meters maintaining the same EPSG code to 3857 and using 500*500 for res X and resY but it shows an invalid response in the background you can see I have unchecked resolution in meters.

But when I tried using a value of 1000 or above it downloads the image and the resolution of the image is around 1000*1000 meters.

6

Kindly let me know where am I going wrong or is there anything in the code that needs to be adjusted?

FOR RESOLUTION IN METERS WITH 500 X AND Y RESOLUTION
curl -X POST https://creodias.sentinel-hub.com/api/v1/process
-H ‘Content-Type: application/json’
-H ‘Authorization: Bearer token’
-d ‘{
“input”: {
“bounds”: {
“geometry”: {
“type”: “Polygon”,
“coordinates”: [
[
[
-17325124.285874,
10164099.147192
],
[
-17840351.261375,
9942081.014397
],
[
-17856693.817134,
9406315.992829
],
[
-17945241.746287,
9123241.101054
],
[
-17996301.27797,
8741174.216142
],
[
-15666493.37151,
8789581.808807
],
[
-15632807.824716,
10626689.308241
],
[
-17344303.465751,
10479247.243331
],
[
-17325124.285874,
10164099.147192
]
]
]
},
“properties”: {
“crs”: “http://www.opengis.net/def/crs/EPSG/0/3857
}
},
“data”: [
{
“type”: “S3SLSTR”,
“dataFilter”: {
“timeRange”: {
“from”: “2018-05-02T00:00:00Z”,
“to”: “2018-05-02T23:59:59Z”
},
“maxCloudCoverage”: 4
}
}
]
},
“output”: {
“width”: 2245.653766240245,
“height”: 1580.389705482169,
“responses”: [
{
“identifier”: “default”,
“format”: {
“type”: “image/tiff”
}
}
]
},
“evalscript”: "//VERSION=3\nfunction setup() {\n return {\n input: [“S2”],\n output: { bands: 1, sampleType: “FLOAT32” }\n };\n}\n\nfunction evaluatePixel(sample) {\nreturn [sample.S2];\n}\n "
}’

EVALSCRIT:
//VERSION=3
function setup() {
return {
input: [“S2”],
output: { bands: 1, sampleType: “FLOAT32” }
};
}

function evaluatePixel(sample) {
return [sample.S2];
}

WITH UNCHECKED RESOLUTION IN METERS AND THE SAME RESOLUTION OF 500 BUT SHOWS INVALID RESPONSE

curl -X POST https://creodias.sentinel-hub.com/api/v1/process
-H ‘Content-Type: application/json’
-H ‘Authorization: Bearer token’
-d ‘{
“input”: {
“bounds”: {
“geometry”: {
“type”: “Polygon”,
“coordinates”: [
[
[
-17325124.285874,
10164099.147192
],
[
-17840351.261375,
9942081.014397
],
[
-17856693.817134,
9406315.992829
],
[
-17945241.746287,
9123241.101054
],
[
-17996301.27797,
8741174.216142
],
[
-15666493.37151,
8789581.808807
],
[
-15632807.824716,
10626689.308241
],
[
-17344303.465751,
10479247.243331
],
[
-17325124.285874,
10164099.147192
]
]
]
},
“properties”: {
“crs”: “http://www.opengis.net/def/crs/EPSG/0/3857
}
},
“data”: [
{
“type”: “S3SLSTR”,
“dataFilter”: {
“timeRange”: {
“from”: “2018-05-02T00:00:00Z”,
“to”: “2018-05-02T23:59:59Z”
},
“maxCloudCoverage”: 4
}
}
]
},
“output”: {
“resx”: 500,
“resy”: 500,
“responses”: [
{
“identifier”: “default”,
“format”: {
“type”: “image/tiff”
}
}
]
},
“evalscript”: "//VERSION=3\nfunction setup() {\n return {\n input: [“S2”],\n output: { bands: 1, sampleType: “FLOAT32” }\n };\n}\n\nfunction evaluatePixel(sample) {\nreturn [sample.S2];\n}\n "
}’

Any help will be highly appreciated and thank you in advance.

Hi @vasudhachaturvedi18

First of all, you will notice that I edited all your posts to remove the bearer token that you copied. That is because anybody can parse the token and retrieve your name + email address and other info. Please make sure when you post requests in the future to remove the bearer token if you don’t want private info exposed.

But after downloading a single day image the pixel size shows twice the value of resolution as I mentioned, but on actually manually measuring the pixel using ArcPRO it shows values below 500 for both x and y axis not exact 500.

That is because you can measure distance in two different ways. Having checked in QGIS, the cell size that you show in the source tab (1052*1193) is the resolution based on the Cartesian calculation. When you measure manually with ArcPRO you are actually finding the resolution based on an ellipsoidal calculation. The difference between the two depends on the projection used and the deformation. The reason that the ellipsoid-based width of a pixel is slightly different than exactly 500m is due to the reprojection of the data that is done in the background. Furthermore, note that “meters” as defined in “EPSG:3857” projection are very “distorted” and can be far from meters in reality. There are many resources online to understand the differences.

For info, the “resolution in meters” option works in the following way: it uses the Haversine formula to calculate the number of meters of the bbox and tries to set width/height to fulfill that… So your mileage may vary depending on location, projection etc…

I tried turning off the resolution in meters maintaining the same EPSG code to 3857 and using 500*500 for res X and resY but it shows an invalid response in the background you can see I have unchecked resolution in meters.

When you get an error that is not very explicit such as this one, you can open the developer console (usually with F12), and note the error message linked to the failed request in the console. In this case the error is that you are trying to generate a raster that is larger than the maximum allowance of 2500*2500 pixels. But I admit that the error message should be clearer!

Okay, I will be more careful next time. And thank you for the brief clarification.