Skip to main content

Hi there,

I was wondering how to get the output of a WcsRequest as json instead of PNG, JPG and so on.

This is the request code:


wms_bands_request = WcsRequest(
data_collection=DataCollection.SENTINEL2_L2A,
data_folder='test_dir',
layer='NDVI',
bbox=betsiboka_bbox,
time=('2017-12-16', '2017-12-31'),
resx='60m',
resy='60m',
image_format=MimeType.JSON,
config=config
)

By following the doc, I’ve been able to understand that sentinelhub.constants.MimeType.TIFF it also provides JSON (by here).


I got this error (400 bad request):

Server response: “Format image/png does not support sample type FLOAT32.”


When it comes to Output Image Formats I clearly see JSON as possible choice, but can’t figure out how to make it works actually.


Let’s consider the “NDVI” problem. If I try to plot the response, I just got this image as follow, instead of all the NDVIs from the image. The original image is based on BANDS-S2-L1C layer and is just ‘normal size image’, like a country image (I cannot post 2 images as new user, sorry).



I would also suggest to make the output vector format doc more precise, just in case (or maybe I’m missing something!)

Thank you!

I am not sure I understand, what you would like to do.


The “vector output” option was added to WCS as a “test feature” a while ago and remained there as it is convenient for some users (typical use-case is creating a zoning map of an agriculture parcel based on thresholded NDVI). The feature is there and works, but it was not developed further as it is quite a niche use-case. This is also why the sentinelhub-py libraries do not support it out-of-the-box. You can obviously make an API request yourself in Python and get a GeoJSON.


If however you are interested in creating a histogram of NDVI values over specific area, I would recommend to use Statistical API, which was designed exactly for this purpose - you will get min/max/mean/standard deviation values and, if you add BINS parameter, also distribution. See implementation in sh-py:

sentinelhub-py.readthedocs.io

Sentinel Hub Feature Info Service (FIS) — Sentinel Hub 3.1.0 documentation








Hi! Thanks for your reply.

 

You can obviously make an API request yourself in Python and get a GeoJSON

That’s exactly what I would like to achieve! I don’t need to plot a NDVI map, but I definitely need a GeoJSON and I can’t figure out how to get as output this GeoJSON instead of a PNG inside a WcsRequest…


I think you will have to construct a WCS request yourself. It should not be too difficult…

I somehow doubt that we will add this feature to sh-py soon as it is an experimental one.


Ok but what is the correct sentinelhub.constants to use in order to be able to use “NDVI” as layer?

If I set:

layer=‘NDVI’


instead of (for example):

layer=‘BANDS-S2-L1C’


I get this error: ““Format image/png does not support sample type FLOAT32.””

But “NDVI” is a possible layer to choose…

Not talking about the GeoJSON problem right now, just how to get the NDVI layer properly…


Not sure exactly what you want to achieve at this point.

If you want to get actual NDVI values, you can set-up a layer as shown here:

e858d96b2d4601f1ebd0b61b557c5c16ccb1b57a.pngsentinel-hub.com
d3714e73b38a87afa3c31502a6696052a7395163.png


FAQ



Check our list of frequently asked questions and answers on Sentinel Hub services.








image_format=MimeType.TIFF_d32f


This is what I was looking for, found in another question here (I’ve been lucky honestly xD)

Thank you!


Reply