Improve error message in case an input image is empty (AttributeError: 'NoneType' object has no attribute 'geom_type')
Currently, in this case, AROSICS fails with:
../findr_homo/homogenization/homogenizer.py:65: in homogenize_landsat8
SpatH.compute_shifts(ri, l8)
../findr_homo/homogenization/spatial.py:66: in compute_shifts
self._CRL = COREG_LOCAL(ref.data, tgt.data, 50, max_points=1000, CPUs=None,
../../../../mambaforge/envs/findr/lib/python3.10/site-packages/arosics/CoReg_local.py:329: in __init__
self.COREG_obj = COREG(self.imref, self.im2shift,
../../../../mambaforge/envs/findr/lib/python3.10/site-packages/arosics/CoReg.py:413: in __init__
self._get_image_params()
../../../../mambaforge/envs/findr/lib/python3.10/site-packages/arosics/CoReg.py:548: in _get_image_params
self.shift = GeoArray_CoReg(self.params, 'shift')
../../../../mambaforge/envs/findr/lib/python3.10/site-packages/arosics/CoReg.py:120: in __init__
_ = self.footprint_poly # execute getter
../../../../mambaforge/envs/findr/lib/python3.10/site-packages/geoarray/baseclasses.py:664: in __getattr__
return self.__getattribute__(attr) # __getattribute__ avoids infinite loop
../../../../mambaforge/envs/findr/lib/python3.10/site-packages/geoarray/baseclasses.py:508: in footprint_poly
self._footprint_poly = fill_holes_within_poly(multipolygon)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
poly = None
def fill_holes_within_poly(poly: Union[Polygon, MultiPolygon]
) -> Polygon:
"""Fill the holes within a shapely Polygon or MultiPolygon and return a Polygon with only the outer boundary.
:param poly: <shapely.geometry.Polygon, shapely.geometry.MultiPolygon>, shapely.geometry.GeometryCollection>
:return:
"""
def close_holes(polygon: Polygon) -> Polygon:
if polygon.interiors:
return Polygon(list(polygon.exterior.coords))
else:
return polygon
> if poly.geom_type not in ['Polygon', 'MultiPolygon']:
E AttributeError: 'NoneType' object has no attribute 'geom_type'