I want to calculate the number of pixcell of a geometry that their NDVI is greater than 0.3. how can i do that?
Hi @sabatabesh ,
I’d suggest using Statistical API and create a histogram with arbitrary bins.
An example would be the following:
curl -X POST https://services.sentinel-hub.com/api/v1/statistics \
-H 'Authorization: Bearer ' \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"input": {
"bounds": {
"bbox": [
4526313.815668,
2089673.283266,
4530446.599833,
2092523.566946
],
"properties": {
"crs": "http://www.opengis.net/def/crs/EPSG/0/3035"
}
},
"data": [
{
"dataFilter": {},
"type": "sentinel-2-l2a"
}
]
},
"aggregation": {
"timeRange": {
"from": "2023-05-01T00:00:00Z",
"to": "2023-05-30T23:59:59Z"
},
"aggregationInterval": {
"of": "P1D"
},
"resx": "10",
"resy": "10",
"evalscript": "//VERSION=3\nfunction setup() {\n return {\n input: [{\n bands: [\n \"B04\",\n \"B08\",\n \"dataMask\"\n ]\n }],\n output: [\n {\n id: \"ndvi\",\n bands: 1\n },\n {\n id: \"dataMask\",\n bands: 1\n }]\n };\n}\n\nfunction evaluatePixel(samples) {\n let index = (samples.B08 - samples.B04) / (samples.B08+samples.B04);\n return {\n ndvi: [index],\n dataMask: [samples.dataMask],\n };\n}\n"
},
"calculations": {
"ndvi": {
"histograms": {
"default": {
"bins": [
"-1.0",
"0.3",
"1.0"
]
}
}
}
}
}'
This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.