From 1a15579d9723983013eeaeb8baddbd26169451f0 Mon Sep 17 00:00:00 2001 From: Andrew Player Date: Wed, 20 Dec 2023 11:55:38 -0600 Subject: [PATCH] insar_roi is now the corner of the burst --- src/hyp3_isce2/burst.py | 13 +++++++------ src/hyp3_isce2/insar_tops_burst.py | 5 ++++- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/hyp3_isce2/burst.py b/src/hyp3_isce2/burst.py index fbfeda14..6f751142 100644 --- a/src/hyp3_isce2/burst.py +++ b/src/hyp3_isce2/burst.py @@ -30,6 +30,7 @@ class BurstParams: swath: str polarization: str burst_number: int + extent: List[int] class BurstMetadata: @@ -248,7 +249,7 @@ def get_isce2_burst_bbox(params: BurstParams, base_dir: Optional[Path] = None) - def get_region_of_interest( - ref_bbox: geometry.Polygon, sec_bbox: geometry.Polygon, is_ascending: bool = True + ref_extent: geometry.Polygon, sec_extent: geometry.Polygon, is_ascending: bool = True ) -> Tuple[float]: """Get the region of interest for two bursts that will lead to single burst ISCE2 processing. @@ -263,11 +264,10 @@ def get_region_of_interest( Returns: The region of interest as a tuple of (minx, miny, maxx, maxy). """ - intersection = ref_bbox.intersection(sec_bbox) - bounds = intersection.bounds - - x, y = (0, 1) if is_ascending else (2, 1) - roi = geometry.Point(bounds[x], bounds[y]).buffer(0.005) + intersection = ref_extent.intersection(sec_extent) + exterior_coords = intersection.exterior.coords[:] + idx = 5 if is_ascending else 3 + roi = geometry.Point(exterior_coords[idx]).buffer(0.005) return roi.bounds @@ -379,6 +379,7 @@ def get_burst_params(scene_name: str) -> BurstParams: swath=results[0].properties['burst']['subswath'], polarization=results[0].properties['polarization'], burst_number=results[0].properties['burst']['burstIndex'], + extent=results[0].geometry['coordinates'][0] ) diff --git a/src/hyp3_isce2/insar_tops_burst.py b/src/hyp3_isce2/insar_tops_burst.py index 5db736b9..21e0b44f 100644 --- a/src/hyp3_isce2/insar_tops_burst.py +++ b/src/hyp3_isce2/insar_tops_burst.py @@ -20,6 +20,7 @@ from lxml import etree from osgeo import gdal from pyproj import CRS +from shapely.geometry import Polygon import hyp3_isce2 import hyp3_isce2.metadata.util @@ -92,8 +93,10 @@ def insar_tops_burst( is_ascending = ref_metadata.orbit_direction == 'ascending' ref_footprint = get_isce2_burst_bbox(ref_params) sec_footprint = get_isce2_burst_bbox(sec_params) + ref_extent = Polygon(ref_params.extent) + sec_extent = Polygon(sec_params.extent) - insar_roi = get_region_of_interest(ref_footprint, sec_footprint, is_ascending=is_ascending) + insar_roi = get_region_of_interest(ref_extent, sec_extent, is_ascending=is_ascending) dem_roi = ref_footprint.intersection(sec_footprint).bounds log.info(f'InSAR ROI: {insar_roi}') log.info(f'DEM ROI: {dem_roi}')