Skip to main content

Because of the character limit in the URL I used the POST request to retrieve statistical information. But I got very low NDVI values. So I used the get_data method and the POST request to compare the statistical information for the same polygon. The results are quite different. Can somebody explain me why? Thanks


Here is the configuration for the get_data method:


from sentinelhub import SHConfig, CRS, constants, FisRequest, Geometry
from shapely.geometry import Polygon

class configuration:
def use_modis():
sh_config = SHConfig()
sh_config.instance_id = <INSTANCE_ID>
sh_config.ogc_base_url = 'https://services-uswest2.sentinel-hub.com/v1/'
sh_config.save()

configuration.use_modis()

geometry1 = Geometry(Polygon([(9.888827680050385, 48.51217273580289),
(9.89264918894377, 48.51226462256068),
(9.893282254167623, 48.51638404099815),
(9.889316705153087, 48.51622619699188),
(9.888827680050385, 48.51217273580289)]),
CRS.WGS84)

fis_request = FisRequest(layer=<NDVI_LAYER>,
geometry_list=[geometry1],
time='2019-05-11',
resolution='500m',
instance_id=<INSTANCE_ID>,
data_source=constants.DataSource.MODIS
)
fis_data = fis_request.get_data(save_data=False)

fis_data
[{'C0': [{'basicStats': {'max': 0.8196691274642944,
'mean': 0.8196691274642944,
'min': 0.8196691274642944,
'stDev': 0.0},
'date': '2019-05-11'}]}]

And here is the post request:


import requests

url = 'https://services-uswest2.sentinel-hub.com/ogc/fis/'+<INSTANCE_ID>

response = requests.post(url,
headers={
'Accept': 'application/json, text/plain, */*',
'Content-Type': 'application/json; charset=utf-8',
'Connection': 'keep-alive'
},
json={
"layer":<NDVI_LAYER>,
"crs":"EPSG:4326",
"time":"2019-05-11/2019-05-11",
"resolution":"500m",
"geometry":"POLYGON ((9.888827680050385 48.51217273580289, 9.89264918894377 48.51226462256068, 9.893282254167623 48.51638404099815, 9.889316705153087 48.51622619699188, 9.888827680050385 48.51217273580289))",
"maxcc":100
}
)

response.json()
{'C0': [{'basicStats': {'max': 0.11925021559000015,
'mean': 0.11925021559000015,
'min': 0.11925021559000015,
'stDev': 0.0},
'date': '2019-05-11'}]}

When I download the MODIS scene and calculate the NDVI manually, I got the same value like with the FIS get_data method.

That looks strange.

Can you perhaps post here CURL requests for both of these options, masking the second part of the instance ID?


CURL for the post request:


curl -X POST \
https://services-uswest2.sentinel-hub.com/ogc/fis/26851e57-6722-495e-second-part-of-instance-id \
-H 'Accept: application/json, text/plain, */*' \
-H 'Connection: keep-alive' \
-H 'Content-Type: application/json; charset=utf-8' \
-d '{"layer":"MODIS_NDVI","crs":"EPSG:4326","time":"2019-05-11/2019-05-11","resolution":"500m","geometry":"POLYGON ((9.888827680050385 48.51217273580289, 9.89264918894377 48.51226462256068, 9.893282254167623 48.51638404099815, 9.889316705153087 48.51622619699188, 9.888827680050385 48.51217273580289))","maxcc":100}'

I don’t know how to create a curl request from get_data method. I did the FIS request in a jupyter notebook like it is shown right here


//edit: Here is the URL for the get_data method:
https://services-uswest2.sentinel-hub.com/ogc/fis/26851e57-6722-495e-second-part-of-instance-id?SERVICE=fis&CRS=EPSG%3A4326&RESOLUTION=500m&MAXCC=100.0&LAYER=MODIS_NDVI&GEOMETRY=POLYGON+((48.51217273580289+9.888827680050385%2C+48.51226462256068+9.89264918894377%2C+48.51638404099815+9.893282254167623%2C+48.51622619699188+9.889316705153087%2C+48.51217273580289+9.888827680050385))&TIME=2019-05-11T00%3A00%3A00%2F2019-05-11T23%3A59%3A59


The difference between these calls is an order of lat/lon in the GEOMETRY parameter.


A WKT representation of a geometry describing the region of interest.

This is a common issue with EPSG:4326, a consequence of a confusion in OGC standard

As stated in the Statistical API page:



Note that WCS 1.1.1 standard is used here, so for EPSG:4326 coordinates should be in latitude/longitude order.



Well, yeah, thats quite confusing! Thanks a lot


Reply