Skip to main content

Hello,


I’m getting started accessing the Process API (S2L1C) and I need to get the minimum, maximum and average ndvi from a polygon.


I’ve already getting the TIFF file with the desired colors, but I don’t know where to start to get those values in the response.


I’m using CURL and PHP.


Any help would be appreciated.

Hi @marcos.fbc,


the easiest way is to use a dedicated API for this - Statiatical API.


The other option is using updateOutputMetadata function of the custom script as demonstrated in Tip 6 in this blog:

360db83263e79cba7951e7ba15aa4495131aa0f1.pngMedium – 15 Jun 21
f698a7e3e9c8a094ef9a83b2c615fb7ea6a69c30.png


Custom scripts: faster, cheaper, better!



15 tips for better scripts and more responsive requests




Reading time: 7 min read







Thanks for your quick response.

I`ll try both today.


Hi @gmilcinski,


Thanks again for your response.

I’m trying to use Statiacical API, but when I changed the region using GEOMETRY the response was empty.


Actually I needed to add RESX and RESY to my request as well.


http://services.sentinel-hub.com/ogc/fis/4f9e0919-3206-MASKED?LAYER=VEGETATION-INDEX-NDVI&STYLE=INDEX&CRS=EPSG:3857&TIME=2018-11-15%2F2020-05-15&GEOMETRY=POLYGON((-54.08952876561413 -27.98739282040455,-54.08336551369231 -27.98760544600711,-54.08459142114501 -27.98144772947314,-54.08738735387322 -27.97536276995694,-54.08843974280309 -27.97533191400677,-54.08908634398883 -27.97588577227436,-54.09016603092668 -27.97696274098633,-54.09139788028573 -27.97760384874638,-54.08986613010527 -27.98277768003278,-54.08952876561413 -27.98739282040455))&MAXCC=5&RESX=512&RESY=512


Any ideas why is it happening?


There are several problems in your request:


  • CRS is defined as EPSG:3857, yet your geometry is provided in EPSG:4326

  • geometry should be provided in latitude/longitude order

  • RESX and RESY should not appear in Statistical API, used RESOLUTION instead

  • RESOLUTION should be provided in the same units as the CRS, e.g. in degrees in your case; there is an exception in case of Statistical API, that you can use RESOLUTION=10m if you want us to give a best try to convert these “10 meters into degrees at your latitude”

Applying all of this you get a request, that works:


http://services.sentinel-hub.com/ogc/fis/4f9e0919-3206-4690-MASKED?LAYER=VEGETATION-INDEX-NDVI&STYLE=INDEX&CRS=EPSG:4326&TIME=2018-11-15%2F2020-05-15&GEOMETRY=POLYGON((-27.98739282040455 -54.08952876561413, -27.98760544600711 -54.08336551369231, -27.98144772947314 -54.08459142114501, -27.97536276995694 -54.08738735387322, -27.97533191400677 -54.08843974280309, -27.97588577227436 -54.08908634398883, -27.97696274098633 -54.09016603092668, -27.97760384874638 -54.09139788028573, -27.98277768003278 -54.08986613010527, -27.98739282040455 -54.08952876561413))&MAXCC=5&RESOLUTION=10m


Note that I have masked part of your instance ID to prevent other readers of this forum to abuse it.


@gmilcinski,


I already tested here and it’s working fine.


Thank you for your help


Hi guys


Did you have any examples of the kinds of results were generated here?


Reply