Server response: "Output image area of 12127 x 6809 is too large! Should be at most 5000 x 5000 pixels."

Hello,

I have shapefile with many polygons (571 polygons with 10 columns, the last columnm is the geometry).
I would like to get for each plot the mean NDVI value for one year period.

In order to do that I have uploaded the shapefile, read is as geopandas,created bbox, generated time_interval value and created fis_request, but I got error :

shape = gpd.read_file(r'shape/polygons.shp')
time_interval = ('2020-01-01', '2020-12-31')


def get_bbox_from_shape(shape,resolution):
    minx, miny, maxx, maxy = shape.geometry.total_bounds
    bbox_coords_wgs84=[minx, miny, maxx, maxy]
    bbox = BBox(bbox=bbox_coords_wgs84, crs=CRS.WGS84)
    bbox_size = bbox_to_dimensions(bbox, resolution=resolution)
    return bbox_size,bbox,bbox_coords_wgs84

fis_request = FisRequest(
    data_collection=DataCollection.SENTINEL2_L1C,
    layer='BANDS-S2-L1C',
    geometry_list=bbox,
    time=time_interval,
    resolution='10m',
    data_folder='./data',
    config=config
)


fis_data = fis_request.get_data(save_data=True) 

DownloadFailedException: Failed to download from:
https://services.sentinel-hub.com/ogc/fis/312c5649-0347-41c1-99c3-6c3b2a9f4778
with HTTPError:
400 Client Error: Bad Request for url: https://services.sentinel-hub.com/ogc/fis/312c5649-0347-41c1-99c3-6c3b2a9f4778
Server response: “Output image area of 12127 x 6809 is too large! Should be at most 5000 x 5000 pixels.”

I understand that the problem is the size so I have tried also to get only data for polygons (as I don’t need all the bbox data, I need only the polygons data):

 fis_request = FisRequest(
    data_collection=DataCollection.SENTINEL2_L1C,
    layer='BANDS-S2-L1C',
    geometry_list=shape.iloc[:,9],
    time=time_interval,
    resolution='10m',
    data_folder='./data',
    config=config
)

but then I get this error:

AttributeError: ‘NoneType’ object has no attribute ‘crs’

My end goal is to get NDVI time series statistic for each polygon (e.g the mean NDVI value for each polygon for each available date).

where is my mistake? I guess is something with the shapefile but don’t know how to solve it at the moment.

EDIT: I have also tried to convert my shapefile to shapely with geojson in the middle but still got the same error:

import json
from shapely.geometry import shape, GeometryCollection

shapes.to_file("shapes.geojson",driver='GeoJSON')


with open("shapes.geojson") as f:
    features = json.load(f)["features"]

test=GeometryCollection([shape(feature["geometry"]).buffer(0) for feature in features])

fis_request = FisRequest(
    data_collection=DataCollection.SENTINEL2_L1C,
    layer='BANDS-S2-L1C',
    geometry_list=test,
    time=time_interval,
    resolution='10m',
    data_folder='./data',
    config=config
)

AttributeError: ‘Polygon’ object has no attribute ‘crs’

If you want to get NDVI values for each of the polygons, you will have to write a short “for loop”, running Statistical API (FIS) for each of the polygons separately.
We are working on the next version of the Statistical API, which will also have a “Batch processing option”, but this will take some time.
Still, I think it should not be too difficult to run FIS 571-times. You could even do it in several parallel threads to make it faster.

So if I understand correct the issue is the size of the request? it has nothing to do with upgrade my user? or that tasks like this could be run only by for loop?

There are two separate issues here:

  1. individual request should not be larger than 2500x2500 px (5000x5000 is a wrong error message)
  2. Statistical API (FIS) will return only one result for the geometry you provide

First problem can be easily solved by changing a resolution, e.g. to 50m. As you are interested in statistics, if you are running a request over the large area, these will be the same if you use 10m or 50m resolution.

The second problem, assuming you want to get mean NDVI value for each of the polygons separately, will require you to execute FIS request for each polygon separately.

None of these two issues is related to the type of the account. That being said, if you have larger account, you can run more requests (and mroe of them in parallel).

1 Like