Closed dshean closed 2 years ago
Hi @dshean. I have been using your package for a project and I was wondering if the feature you mention here will be implemented any time soon, or if there is any draft or as you say notes on how to do this. It would be really helpful! Thanks!
Hi Lorena, Not notes perse, but for now you could use something like this:
clip_raster_by_shp.py
in the terminal.clip_raster_by_shp.py refdem.tif exclude_area.shp -invert
. This will produce a new refdem_shpclip.tif
file which wont have areas which you do not want to be used in co-registration.dem_align.py refdem_shpclip.tif source_dem.tif
, to align your source DEM to reference DEM, with areas which you wanted to exclude not used during coregistration.
Cheers,
ShashankHi @ShashankBice, thank you for the tips and workflow! It all makes sense, but before trying this I have one doubt. If I run dem_align.py refdem_shpclip.tif source_dem.tif
I assume that I will basically get an incomplete result (since I will not be providing a filtered DEM to the function). For me the value of the masking is that one can exclude areas that are known to be unstable, and then still coregister these areas based on the stable terrain. With the steps you just pointed out to me, I will be losing the unstable areas all together, is that right?
Hi @loreabad6. There are several ways to go about this. You can use a GIS to create a new vector dataset, then manually define polygons over 1) surfaces you want to use for co-registration (e.g., exposed bedrock), or 2) surfaces that you want to exclude during co-registration (e.g., changing surfaces, vegetation).
If you do 1, you can clip the reference DEM to just those surfaces using the default behavior in clip_raster_by_shp.py
. If you do 2, you need to include the -invert
flag, which will preserve reference DEM pixels over the stable surfaces.
I suggest you test this and preview the output to verify that the clipped DEM you produce includes only the surfaces you want to use for co-registration.
When you run dem_align.py, the source DEM requiring alignment will be clipped to stable areas defined by your clipped refdem for the calculations, but the but the final output with resulting translation applied will not be clipped. Hopefully that makes sense.
Hi and thank you both @dshean and @ShashankBice! This makes absolute sense, I just missed the part of clipping the reference and not the source DEM. It works perfect. Thank you for the steps and the great work!
Glad to hear it!
At least add some notes on how to do this to FAQ/doc.
Can rasterize polygon shp (see
gdal_rasterize
or other tutorials), and then create a masked version of reference dem using the pygeotoolsapply_mask.py
function, preserving the "static/stable" pixels (see invert option if necessary). Then provide the masked reference DEM todem_align.py
Review code that does the masking using the RGI polygons. Could accept vector fiilename there, but likely issues with BYO files, missing projection info, etc.
Probably best to review latest material on rasterio/geopandas for these operations, and to start updating this functionality in demcoreg tools.