Request Builder Size vs Resolution

The request builder does not allow for using the resolution parameter instead of size.
When I try to define a resolution this is always converted to size.

Trying to download an imagery using the same code as the request builder but using the resolution parameter (with the automatic values that are shown on the request builder when changing the output to the resolution option) give me an error on response:

400 Client Error: Bad Request for url: https://services.sentinel-hub.com/api/v1/process
Server response: “{“error”:{“status”:400,“reason”:“Bad Request”,“message”:“The bounding box area is too large! Please zoom in.”,“code”:“RENDERER_EXCEPTION”}}”

It is mentioned that the output resolution should be the same as CRS.
I select the CRS EPSG:4326 but the bounding box is converted to WGS84 in the sh-py.

I want to download an image for a polygon with 5 meters resolution (will use upsampling) using as CRS EPSG:4326 - I can’t set this in my code. Any advice on how to configure the request to use a resolution of 5x5m and set EPSG:4326 for the response in the python sentinelhub library?

evalscript = """
    //VERSION=3

    function setup() {
      return {
        input: ["B02", "B03", "B04"],
        output: { bands: 3 }
      };
    }

    function evaluatePixel(sample) {
      return [2.5 * sample.B04, 2.5 * sample.B03, 2.5 * sample.B02];
    }
    """
    bbox = BBox(bbox=[12.294703, 41.828385, 12.32698, 41.841175], crs=CRS.WGS84)

    request = SentinelHubRequest(
        evalscript=evalscript,
        input_data=[
            SentinelHubRequest.input_data(
                data_collection=DataCollection.SENTINEL2_L2A,
                time_interval=('2022-02-09', '2022-03-09'),
            ),
        ],
        responses=[
            SentinelHubRequest.output_response('default', MimeType.JPG),
        ],
        bbox=bbox,
        resolution=[5, 5],
        config=config
    )

    response = request.get_data()

Hi Felipe,

If you are specifying EPSG:4326 as CRS specified resolution will have units of degrees instead of meters as resolution works in the units of the specified CRS.

To get a 5x5 meters request you can either use the option that Requests builder offers, selecting resolution and resolution in meters. This will set width and height accordingly to try to get closest to the specified amount of meters (this can result in huge requests that will be rejected by the service depending on the area of interest).

Another option is to use the utilities of sh-py package as follows:

from sentinelhub import to_utm_bbox, bbox_to_dimensions

utm_bbox = to_utm_bbox(wgs_bbox)
size = bbox_to_dimensions(utm_bbox, 5)

And set that size in the request.

In any case, trying to specify resolution in meters using WGS CRS can result in errors as the calculations will always be an approximation.

Hope this helps,

Ignasi Espinosa

1 Like