st2berry
st2berry

Reputation: 33

How to extract Sentinel-2 RGB images at a custom spatial resolution (16m/pixel) when native band resolution is 10m?

I'm trying to extract a Sentinel-2 L2A dataset containing RGB images, in the span of some years, following this documentation: https://documentation.dataspace.copernicus.eu/notebook-samples/sentinelhub/introduction_to_SH_APIs.html#process-api

My specifications are as follows:

Since the main focus lies on these 2 parameters, the following lines of code are of interest:

def get_true_color_request(time_interval, bbox, size, config):

    evalscript_true_color = """
    //VERSION=3

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

    function evaluatePixel(sample) {
        return [sample.B04, sample.B03, sample.B02];
    }
     """
    return SentinelHubRequest(
        evalscript=evalscript_true_color,
        input_data=[
            SentinelHubRequest.input_data(
                data_collection=DataCollection.SENTINEL2_L2A.define_from(
                    "s2l2a", service_url=config.sh_base_url
                ),
                time_interval=time_interval,
                mosaicking_order=MosaickingOrder.LEAST_CC
            )
        ],
        responses=[SentinelHubRequest.output_response("default", MimeType.PNG)],
        bbox=bbox,
        size=size,
        config=config,
    )
resolution = 10
aoi_bbox = BBox(bbox=aoi_coords_wgs84, crs=CRS.WGS84)
aoi_size = bbox_to_dimensions(aoi_bbox, resolution=resolution)
print(f"Image shape at {resolution} m resolution: {aoi_size} pixels")

My problem lies mainly in this part of the code, because if I write resolution = 16, how will that be achieved? The bands I'll be using are B02, B03 & B04, which correspond to RGB, and for Sentinel-2A, the resolution for all 3 bands, is 10 m/pixel, as seen here.

Thing is, I actually did run the code, writing resolution = 16, and it did produce some images without any error popping up, but I’m unsure if they truly have a 16 m/pixel resolution.

Upvotes: 2

Views: 74

Answers (0)

Related Questions