Hi,
If you want the values without having to do the conversion step for NDVI, you can change the sampleType
to “FLOAT32” and return undvi];
in your evaluatePixel
function.
To work with large areas such as yours but request data at higher resolution, you have two options:
Maxim
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,
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.
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.
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”:
/
t
-17325124.285874,
10164099.147192
],
9
-17840351.261375,
9942081.014397
],
1
-17856693.817134,
9406315.992829
],
5
-17945241.746287,
9123241.101054
],
1
-17996301.27797,
8741174.216142
],
4
-15666493.37151,
8789581.808807
],
1
-15632807.824716,
10626689.308241
],
9
-17344303.465751,
10479247.243331
],
7
-17325124.285874,
10164099.147192
]
]
]
},
“properties”: {
“crs”: “http://www.opengis.net/def/crs/EPSG/0/3857”
}
},
“data”: r
{
“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 usample.S2];\n}\n "
}’
EVALSCRIT:
//VERSION=3
function setup() {
return {
input: b“S2”],
output: { bands: 1, sampleType: “FLOAT32” }
};
}
function evaluatePixel(sample) {
return usample.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
],
b
-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”: 2
{
“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 esample.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.