Skip to content

Instantly share code, notes, and snippets.

@scottstanie
Last active January 23, 2024 22:33
Show Gist options
  • Save scottstanie/a4619b7a4dc438bb6cc35b5f1cddd0c8 to your computer and use it in GitHub Desktop.
Save scottstanie/a4619b7a4dc438bb6cc35b5f1cddd0c8 to your computer and use it in GitHub Desktop.
Burst Overlap Interferometry with geocoded SLCs
from os import fspath
import numpy as np
from osgeo import gdal
from dolphin import io, stitching, utils
def compute_boi(ifg_file1: str, ifg_file2: str, looks: tuple[int, int] = (1, 1)) -> np.ndarray:
assert io.get_raster_crs(ifg_file1) == io.get_raster_crs(ifg_file2)
(left, bottom, right, top), nodata = stitching.get_combined_bounds_nodata(
ifg_file1, ifg_file2
)
def grow_bounds(file):
return gdal.Translate(
"",
fspath(file),
format="VRT", # Just creates a file that will warp on the fly
resampleAlg="nearest", # nearest neighbor for resampling
projWin=(left, top, right, bottom),
).ReadAsArray()
out1 = grow_bounds(ifg_file1)
out2 = grow_bounds(ifg_file2)
return utils.take_looks(out1 * out2.conj(), *looks)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment