From c97a3a13831fc014e38c21604eb39fe6087bc64c Mon Sep 17 00:00:00 2001 From: Nate Kean Date: Mon, 15 Sep 2025 01:34:36 -0500 Subject: [PATCH 1/2] Hack: always project GeocodedFile to EPSG:4326 Rest of the code is not properly set up to handle GeocodedFile AOIs that are not in EPSG:4326, which causes problems with EPSG:32617 interferograms from ASF On Demand. I personally lack the time to fix this properly, but I did end up doing this much so that RAiDER would work with my code for the gemlab ASF On Demand notebook jlmaurer/gemlab#11. In the case when the user inputs a geocoded file with projection other than EPSG:4326, this change fixes a crash, at the cost of probably more projection conversion artifacts than necessary from a more in-depth solution. In all other cases (other projections, other input AOI types), nothing is changed/affected. --- tools/RAiDER/llreader.py | 9 ++++----- tools/RAiDER/utilFcns.py | 10 +++++++--- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/tools/RAiDER/llreader.py b/tools/RAiDER/llreader.py index bd1e2d5d..ffa6e83f 100644 --- a/tools/RAiDER/llreader.py +++ b/tools/RAiDER/llreader.py @@ -14,6 +14,8 @@ import pyproj import xarray as xr +from RAiDER.utilFcns import transform_bbox + try: import pandas as pd @@ -330,14 +332,11 @@ def __init__(self, path: Path, is_dem=False, cube_spacing_in_m: Optional[float]= self._filename = path self.p = rio_profile(path) - self._bounding_box = rio_extents(self.p) + self._bounding_box = transform_bbox(rio_extents(self.p), dest_crs=4326, src_crs=32617) self._is_dem = is_dem _, self._proj, self._geotransform = rio_stats(path) self._type = 'geocoded_file' - try: - self.crs = self.p['crs'] - except KeyError: - self.crs = None + self.crs = CRS.from_epsg(4326) def readLL(self) -> tuple[np.ndarray, np.ndarray]: # ll_bounds are SNWE diff --git a/tools/RAiDER/utilFcns.py b/tools/RAiDER/utilFcns.py index 30f22d08..5915f323 100644 --- a/tools/RAiDER/utilFcns.py +++ b/tools/RAiDER/utilFcns.py @@ -4,7 +4,7 @@ import pathlib import re from pathlib import Path -from typing import Any, Optional, Union, cast +from typing import TYPE_CHECKING, Any, Optional, Union, cast import numpy as np import numpy.typing as npt @@ -20,11 +20,15 @@ from RAiDER.constants import _THRESHOLD_SECONDS from RAiDER.constants import _g0 as G0 from RAiDER.constants import _g1 as G1 -from RAiDER.llreader import AOI from RAiDER.logger import logger from RAiDER.types import BB, RIO, CRSLike, FloatArray2D, FloatArray3D +# Only used for type annotations +if TYPE_CHECKING: + from RAiDER.llreader import AOI + + # Optional imports try: import pandas as pd @@ -420,7 +424,7 @@ def round_time(datetime: dt.datetime, roundTo: int=60) -> dt.datetime: def writeDelays( - aoi: AOI, #: AOI, + aoi: 'AOI', wetDelay: ndarray, hydroDelay: ndarray, wet_path: Path, From cacab09401e90f30979e1b523c66a761ccc93d66 Mon Sep 17 00:00:00 2001 From: Nate Kean Date: Mon, 15 Sep 2025 01:47:45 -0500 Subject: [PATCH 2/2] Transform GeocodedFile bbox from file's CRS Instead of hard-coding it --- tools/RAiDER/llreader.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/RAiDER/llreader.py b/tools/RAiDER/llreader.py index ffa6e83f..4bdd0eaf 100644 --- a/tools/RAiDER/llreader.py +++ b/tools/RAiDER/llreader.py @@ -332,7 +332,7 @@ def __init__(self, path: Path, is_dem=False, cube_spacing_in_m: Optional[float]= self._filename = path self.p = rio_profile(path) - self._bounding_box = transform_bbox(rio_extents(self.p), dest_crs=4326, src_crs=32617) + self._bounding_box = transform_bbox(rio_extents(self.p), dest_crs=4326, src_crs=self.p['crs']) self._is_dem = is_dem _, self._proj, self._geotransform = rio_stats(path) self._type = 'geocoded_file'