|
29 | 29 | from sertit import path, vectors |
30 | 30 | from sertit.misc import ListEnum |
31 | 31 | from sertit.types import AnyPathStrType |
| 32 | +from shapely import Polygon |
32 | 33 |
|
33 | 34 | from eoreader import DATETIME_FMT, EOREADER_NAME, cache |
34 | 35 | from eoreader.bands import SarBandNames as sab |
@@ -179,7 +180,30 @@ def wgs84_extent(self) -> gpd.GeoDataFrame: |
179 | 180 | # Some ICEYE products don't have any QUICKLOOK.kml file as it is not a mandatory file! |
180 | 181 | extent_wgs84 = self._fallback_wgs84_extent("QUICKLOOK.kml") |
181 | 182 |
|
182 | | - return gpd.GeoDataFrame(geometry=extent_wgs84.geometry, crs=extent_wgs84.crs) |
| 183 | + # Other fallback |
| 184 | + if extent_wgs84.crs is None: |
| 185 | + root, nsmap = self.read_mtd() |
| 186 | + |
| 187 | + # Some ICEYE product metadata has a namespace some don't |
| 188 | + namespace = nsmap.get(None, "") |
| 189 | + |
| 190 | + # Get lat lon of extent coordinates |
| 191 | + fn = root.findtext(f".//{namespace}coord_first_near").split(" ")[2:] |
| 192 | + ln = root.findtext(f".//{namespace}coord_last_near").split(" ")[2:] |
| 193 | + lf = root.findtext(f".//{namespace}coord_last_far").split(" ")[2:] |
| 194 | + ff = root.findtext(f".//{namespace}coord_first_far").split(" ")[2:] |
| 195 | + |
| 196 | + extent_wgs84 = gpd.GeoDataFrame( |
| 197 | + geometry=[Polygon([fn[::-1], ln[::-1], lf[::-1], ff[::-1]])], |
| 198 | + crs=vectors.WGS84, |
| 199 | + ).envelope |
| 200 | + |
| 201 | + # Drop all columns except important ones |
| 202 | + extent_wgs84 = gpd.GeoDataFrame( |
| 203 | + geometry=extent_wgs84.geometry, crs=extent_wgs84.crs |
| 204 | + ) |
| 205 | + |
| 206 | + return extent_wgs84 |
183 | 207 |
|
184 | 208 | def _set_product_type(self) -> None: |
185 | 209 | """Set products type""" |
|
0 commit comments