Sentinel Hub API returns an array of fixed size 256 x 256

We are currently building an app that utilizes satellite data from Sentinel Hub for capturing two snapshots of Areas of Interest (AOI) before and after incident dates, specifically focusing on bands B8, B2, B3, and B12. These AOIs can vary in size and may include small farms of approximately 1 to 2 acres.

We have noticed that Sentinel Hub returns an array of fixed size 256 x 256 x 4, regardless of the size of the AOI requested. We would like to validate the results based on our AOIs. Is there any way that anyone can assist us in validating the accuracy of the results?

Sentinel Hub returns a fixed size if you specify the “width” and “height” fields in the “output” part of the request, or a size depending on the AoI if you instead specify the output resolution fields “resx” and "resy, like this example. In your case you should probably use the latter option. Note that the resolution must be specified in the same units as the area of interest.

Thanks for your quick response.
I am using below code:

def fetch_bands(date,full_geometry,config):
evalscript = “”"
//VERSION=3

    function setup() {
        return {
            input: [{
                bands: ["B02", "B03", "B04", "B08","dataMask"],
                units: "DN"
            }],
            output: {
                bands: 5,
                sampleType: "INT16"
            }
        };
    }

    function updateOutputMetadata(scenes, inputMetadata, outputMetadata) {
        outputMetadata.userData = { "norm_factor":  inputMetadata.normalizationFactor }
    }

    function evaluatePixel(sample) {
        if (sample.dataMask > 0)  {
            return [sample.B08,sample.B04, sample.B03, sample.B02,sample.dataMask]
      } 
      
    }
    """
    #print(date)
    #print("#########")
    request_multitype = SentinelHubRequest(
        evalscript=evalscript,
        input_data=[
            SentinelHubRequest.input_data(
                data_collection=DataCollection.SENTINEL2_L2A,
                time_interval=(date, date + timedelta(days = 0)),
                mosaicking_order=MosaickingOrder.LEAST_CC,
            )
        ],
    responses=[
        SentinelHubRequest.output_response("default", MimeType.TIFF),
        SentinelHubRequest.output_response("userdata", MimeType.JSON),
    ],
    geometry=full_geometry, 
    #size=(512, 512),
    #bbox=bbox,
       #size=betsiboka_size,
    config=config,
    )
    

# print out information
    multi_data = request_multitype.get_data()[0]


# normalize image
    img = multi_data["default.tif"]
    norm_factor = multi_data["userdata.json"]["norm_factor"]

    img_float32 = img * norm_factor
    #print(full_geometry)

    return img_float32

Here instead of bounding box I am using geometry (sample below)
POLYGON ((76.1397489532828 18.3132526409186, 76.1401244625449 18.3132551872813, 76.140499971807 18.3132344980834, 76.1404697969556 18.3128725958676, 76.1403356865048 18.3125266077297, 76.1398914456367 18.3126068184727, 76.1395283415914 18.3125504799785, 76.1396503821015 18.3130094631094, 76.1397489532828 18.3132526409186))

So I want DN values for this area only? Can you please suggest if above approach is fine or is there any other better approach to do the same?

Yes, this approach is fine. You will get the DN values for each pixel inside your AoI where data is available, and after multiplying with the norm_factor you will get the reflectance.

You could also get float32 reflectance values directly by omitting the units (so that REFLECTANCE would be used) and setting the output sampleType to FLOAT32. Multiplication then would not be needed. However, your proposed approach is cheaper because it avoids the PU multiplication factor of setting the sampleType to FLOAT32.

1 Like

gr8!!! Thanks for your kind suggestions.

Do I really need dataMask? I have gone thru the documentation but was not very clear. Earlier I used dataMask to avoid the null values but it didn’t work well. Can you please educate me on dataMask?

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.