S1 RTC Local Resolution Weighting #234
-
Dear @johntruckenbrodt, I’ll like to seek your help in clearing some questions I have regarding LRW, as I’m seeking to make a national S1 mosaic.
As always, I really appreciate all your support. Saludos. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Dear @alexisahedo, import stackstac
import rioxarray
import numpy as np
from S1_NRB.metadata.stac import make_catalog
# create a STAC catalog from a directory with S1-NRB products
target = '/path/to/s1-nrb/products'
nrb_catalog = make_catalog(directory=target, silent=True)
# load the STAC items into an xarray object
ds = stackstac.stack(items=nrb_catalog,
dtype=np.dtype('float32'),
chunksize=(-1, 1, 1024, 1024),
xy_coords='center')
# get the linear-scaled gamma nought RTC backscatter
vv = ds.sel(band='vv-g-lin')
# get the local contributing area aka scattering area
lca = ds.sel(band='contributing-area')
# compute LRW and log-scale it
weights = 1 / lca
lrw = vv.weighted(weights=weights.fillna(0)).mean(dim='time')
lrw = 10 * np.log10(lrw)
# write the result to COG
lrw.rio.write_nodata(-9999, inplace=True)
lrw.rio.write_crs(lrw['proj:wkt2'].item(), inplace=True)
lrw.rio.to_raster(raster_path='/path/to/output.tif', driver='COG') I am not sure whether the computation is 100% correct though, it is just quick shot I gave it some months ago. |
Beta Was this translation helpful? Give feedback.
Dear @alexisahedo,
pyroSAR and S1_NRB do not directly offer an implementation but it is not too hard to achieve. With S1_NRB output it is pretty easy using STAC and xarray: