xdem.coreg.workflows.dem_coregistration#
- xdem.coreg.workflows.dem_coregistration(src_dem_path, ref_dem_path, out_dem_path=None, coreg_method=None, grid='ref', resample=False, resampling=Resampling.bilinear, shp_list=(), inout=(), filtering=True, dh_max=None, nmad_factor=5, slope_lim=(0.1, 40), random_state=None, plot=False, out_fig=None, estimated_initial_shift=None)[source]#
A one-line function to coregister a selected DEM to a reference DEM.
Reads both DEMs, reprojects them on the same grid, mask pixels based on shapefile(s), filter steep slopes and outliers, run the coregistration, returns the coregistered DEM and some statistics. Optionally, save the coregistered DEM to file and make a figure. For details on masking options, see create_inlier_mask function.
- Parameters:
src_dem_path (
Union
[str
,TypeVar
(RasterType
, bound= Raster)]) – Path to the input DEM to be coregisteredref_dem_path (
Union
[str
,TypeVar
(RasterType
, bound= Raster)]) – Path to the reference DEMout_dem_path (
str
|None
) – Path where to save the coregistered DEM. If set to None (default), will not save to file.coreg_method (
Coreg
|CoregPipeline
|None
) – Coregistration method, or pipeline.grid (
str
) – The grid to be used during coregistration, set either to “ref” or “src”.resample (
bool
) – If set to True, will reproject output Raster on the same grid as input. Otherwise, only the array/transform will be updated (if possible) and no resampling is done. Useful to avoid spreading data gaps.resampling (
Resampling
|None
) – The resampling algorithm to be used if resample is True. Default is bilinear.shp_list (
list
[str
|Vector
] |tuple
[str
|Vector
] |tuple
) – A list of one or several paths to shapefiles to use for masking.inout (
list
[int
] |tuple
[int
] |tuple
) – A list of same size as shp_list. For each shapefile, set to 1 (resp. -1) to specify whether to mask inside (resp. outside) of the polygons. Defaults to masking inside polygons for all shapefiles.filtering (
bool
) – If set to True, filtering will be applied prior to coregistration.dh_max (
Union
[int
,float
,integer
[Any
],floating
[Any
]]) – Remove pixels where abs(src - ref) is more than this value.nmad_factor (
Union
[int
,float
,integer
[Any
],floating
[Any
]]) – Remove pixels where abs(src - ref) differ by nmad_factor * NMAD from the median.slope_lim (
list
[Union
[int
,float
,integer
[Any
],floating
[Any
]]] |tuple
[Union
[int
,float
,integer
[Any
],floating
[Any
]],Union
[int
,float
,integer
[Any
],floating
[Any
]]]) – A list/tuple of min and max slope values, in degrees. Pixels outside this slope range will be excluded.random_state (
int
|Generator
|None
) – Random state or seed number to use for subsampling and optimizer.plot (
bool
) – Set to True to plot a figure of elevation diff before/after coregistration.out_fig (
str
) – Path to the output figure. If None will display to screen.estimated_initial_shift (
list
[Union
[int
,float
,integer
[Any
],floating
[Any
]]] |tuple
[Union
[int
,float
,integer
[Any
],floating
[Any
]],Union
[int
,float
,integer
[Any
],floating
[Any
]]] |None
) – List containing x and y shifts (in pixels). These shifts are applied before the coregistration process begins.
- Return type:
tuple
[DEM
,Coreg
|CoregPipeline
,DataFrame
,ndarray
[Any
,dtype
[floating
[Any
]]]]- Returns:
A tuple containing 1) coregistered DEM as an xdem.DEM instance 2) the coregistration method 3) DataFrame of coregistration statistics (count of obs, median and NMAD over stable terrain) before and after coregistration and 4) the inlier_mask used.