Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 16921

Your request of 5143.88 meters per pixel exceeds the limit 1500.00 meters per pixel of the collection S2L2A. Please revise the resolution

$
0
0

I am getting the error . I am using sentinelapi to download images from sentinel 2 l2a .The user draws polygons in the frontend from the map. (it is using leaflet). I am getting the error and I don't know how to solve this.

Your request of 5143.88 meters per pixel exceeds the limit 1500.00 meters per pixel of the collection S2L2A. Please revise the resolution (or corresponding width/height) to make sure it is in supported range

here is the code that is causing the issue

def get_sentinel_images(field_polygon, start_date, end_date, cloud_cover, selected_area):    area_in_meters =selected_area     # configuration    config = get_config()    # search for the catalogue    geometry = Geometry(geometry=field_polygon, crs=CRS.WGS84)    time_interval = start_date, end_date    catalog = SentinelHubCatalog(config=config)    search_iterator = catalog.search(        DataCollection.SENTINEL2_L2A,        time=time_interval,        filter="eo:cloud_cover < {}".format(cloud_cover),        fields={"include": ["id", "properties.datetime", "properties.eo:cloud_cover"], "exclude": []},        geometry=geometry,    )    results = list(search_iterator)    print("Total number of results:", len(results))    # separating the unique acquisitions    time_difference = dt.timedelta(hours=0)    all_timestamps = search_iterator.get_timestamps()    unique_acquisitions = filter_times(all_timestamps, time_difference)    print("Total number of unique acquisitions:", len(unique_acquisitions))    # make a request to process API for these acquisitions    true_color_evalscript = """    //VERSION=3    function setup() {    return {        input: ["B02", "B03", "B04"],        output: {        bands: 3,        sampleType: "AUTO", // default value - scales the output values from [0,1] to [0,255].        },    }    }    function evaluatePixel(sample) {        return [2.5 * sample.B04, 2.5 * sample.B03, 2.5 * sample.B02]    }"""    nvdi_evalscript =  """//VERSION=3function setup() {  return {    input: [      {        bands: ["B04", "B08"],      },    ],    output: {      id: "default",      bands: 3,    },  }}function evaluatePixel(sample) {  let ndvi = (sample.B08 - sample.B04) / (sample.B08 + sample.B04)  if (ndvi < -0.5) return [0.05, 0.05, 0.05]  else if (ndvi < -0.2) return [0.75, 0.75, 0.75]  else if (ndvi < -0.1) return [0.86, 0.86, 0.86]  else if (ndvi < 0) return [0.92, 0.92, 0.92]  else if (ndvi < 0.025) return [1, 0.98, 0.8]  else if (ndvi < 0.05) return [0.93, 0.91, 0.71]  else if (ndvi < 0.075) return [0.87, 0.85, 0.61]  else if (ndvi < 0.1) return [0.8, 0.78, 0.51]  else if (ndvi < 0.125) return [0.74, 0.72, 0.42]  else if (ndvi < 0.15) return [0.69, 0.76, 0.38]  else if (ndvi < 0.175) return [0.64, 0.8, 0.35]  else if (ndvi < 0.2) return [0.57, 0.75, 0.32]  else if (ndvi < 0.25) return [0.5, 0.7, 0.28]  else if (ndvi < 0.3) return [0.44, 0.64, 0.25]  else if (ndvi < 0.35) return [0.38, 0.59, 0.21]  else if (ndvi < 0.4) return [0.31, 0.54, 0.18]  else if (ndvi < 0.45) return [0.25, 0.49, 0.14]  else if (ndvi < 0.5) return [0.19, 0.43, 0.11]  else if (ndvi < 0.55) return [0.13, 0.38, 0.07]  else if (ndvi < 0.6) return [0.06, 0.33, 0.04]  else return [0, 0.27, 0]}"""    nvdi_process_requests = []    process_requests = []    for timestamp in unique_acquisitions:        request = SentinelHubRequest(            evalscript=true_color_evalscript,            input_data=[                SentinelHubRequest.input_data(                    data_collection=DataCollection.SENTINEL2_L2A.define_from("s2l2a", service_url=config.sh_base_url),                    time_interval=(timestamp - time_difference, timestamp + time_difference),                )            ],            responses=[SentinelHubRequest.output_response("default", MimeType.PNG)],            geometry=geometry,            config=config,        )        process_requests.append((request,timestamp))    print("requesting nvdi images ...")    # repeating the request but for nvdi images    for timestamp in unique_acquisitions:        request = SentinelHubRequest(            data_folder='data_folder',            evalscript=nvdi_evalscript,            input_data=[                SentinelHubRequest.input_data(                    data_collection=DataCollection.SENTINEL2_L2A.define_from("s2l2a", service_url=config.sh_base_url),                    time_interval=(timestamp - time_difference, timestamp + time_difference),                )            ],            responses=[SentinelHubRequest.output_response("default", MimeType.TIFF)],            geometry=geometry,            config=config,)        nvdi_process_requests.append(request)    # download the data     client = SentinelHubDownloadClient(config=config)    download_requests = [request.download_list[0] for request,_ in process_requests]    timestamps = [timestamps for request,timestamps in process_requests]    data = client.download(download_requests)    images = convert_ndarray_to_base64(data)    images_with_timestamps=list(map(list,zip(images,timestamps)))    # arranging the list into descending order(from most recent to oldest)    images_with_timestamps.reverse()    nvdi_process_requests.reverse()    return images_with_timestamps, nvdi_process_requests

What I have done?

I tried adding the size parameter in request class conditionally . This somehow removes the error but I did not get the image with the resolution of 10m per pixels . Like this

 desired_resolution = 10 max_size_in_pixels = 2500 size_in_pixels = int(min(area_in_meters / desired_resolution, max_size_in_pixels))...request = SentinelHubRequest(            evalscript=true_color_evalscript,            input_data=[                SentinelHubRequest.input_data(                    data_collection=DataCollection.SENTINEL2_L2A.define_from("s2l2a", service_url=config.sh_base_url),                    time_interval=(timestamp - time_difference, timestamp + time_difference),                )            ],            responses=[SentinelHubRequest.output_response("default", MimeType.PNG)],            geometry=geometry,            size=(size_in_pixels, size_in_pixels),            config=config,        )

I want to get the images with base resolution of 10 m per pixels . It has been many days I have stuck into this problem. Thanks


Viewing all articles
Browse latest Browse all 16921

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>