AttributeError: 'Polygon' object has no attribute 'crs' when using FIS for polygons

Hello,

I’m trying to get NDVI value for polygon from geodataframe I have. The geodataframe has the geometry as wkt.
The polygon is shapely type :

 type(shapes['geometry'][0])

shapely.geometry.polygon.Polygon

image

However, when I try to run the fis_request, I get error:

fis_request = FisRequest(
    data_collection=DataCollection.SENTINEL2_L2A,
    layer='NDVI_VALUES',
    geometry_list=[shapes['geometry'][0]],
    time=time_interval,
    resolution='10m',
    data_folder='./data2',
    config=config)
    
fis_data = fis_request.get_data(save_data=True) 

----> 3 fis_request = FisRequest(
4 data_collection=DataCollection.SENTINEL2_L2A,
5 layer=‘NDVI_VALUES’,

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

I have tried to fix it by setting crs with shapely but id didnt work:

import pyproj
from shapely.ops import transform
wgs84 = pyproj.CRS('EPSG:4326')


test=shapes['geometry'][0]

fis_request = FisRequest(
    data_collection=DataCollection.SENTINEL2_L2A,
    layer='NDVI_VALUES',
    geometry_list=[transform(shapes['geometry'][0],wgs84)],
    time=time_interval,
    resolution='10m',
    data_folder='./data2',
    config=config)
    
fis_data = fis_request.get_data(save_data=True) 

AttributeError: ‘CRS’ object has no attribute ‘is_empty’

I have also try to use .wkt :

 geometry_list=[shapes['geometry'][0].wkt]

but then I got string which obviously has no crs:

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

I can ttry more ways to set the geometry for the polygons but it confuses me as from the documentatiion says that it suppose to accept the wkt type polygon.

My end goal: to be able to get the FIS for polygon and not for bbox.

thanks in advanced :slight_smile:

just updating that I have solved it by:

from sentinelhub import FisRequest, Geometry, CRS
g=(shapes['geometry'][0])
...
geometry_list=[Geometry(g,CRS.WGS84)],...
...
2 Likes

Great to see you found solution yourself and thanks for sharing this so others can learn as well.

2 Likes