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.iloce:,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)s"features"]
test=GeometryCollection(mshape(featuren"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’