dshean / demcoreg

Utilities for DEM and point cloud co-registration
MIT License
110 stars 42 forks source link

Support for user-provided vector mask #19

Closed dshean closed 2 years ago

dshean commented 4 years ago

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 pygeotools apply_mask.py function, preserving the "static/stable" pixels (see invert option if necessary). Then provide the masked reference DEM to dem_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.

loreabad6 commented 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!

ShashankBice commented 2 years ago

Hi Lorena, Not notes perse, but for now you could use something like this:

loreabad6 commented 2 years ago

Hi @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?

dshean commented 2 years ago

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.

loreabad6 commented 2 years ago

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!

dshean commented 2 years ago

Glad to hear it!