I am trying to generate a normalized DSM by subtracting the original DSM (oDSM) from the DTM.

To generate the DTM I had to first use a median filter on the oDSM (remove noise) and then use a morphological filter on the cleaned oDSM. For the morphological filter I had to convert the oDSM to an 8bit from float32. Now, I need to finally subtract the oDSM from the morphologically operated DSM.

I need to know if subtracting two different data type rasters is a problem. If yes, how can I convert the 8 bit back to a GTIFF? I am working with QGIS and R.

  • I think that the operation that you are trying to perform is a white top-hat transform. See here (gis.stackexchange.com/questions/284026/…) for more details. – WhiteboxDev May 24 '18 at 15:04
  • Please, don't forget to take the tour and read the help center to get acquainted how GIS SE works. You have asked questions (many of them duplicates) and so far limited yourself to provide some feedback in comments asking for more clarification/information, ceasing to vote or accept any useful answers you have received until now. Understanding how the site works will help you getting even more better answers. Tks. – Andre Silva May 24 '18 at 15:43

If I have interpreted your question correctly, I believe that what you are trying to do is to remove the underlying ground surface from your digital surface model (DSM). I would recommend using a white top-hat transform for this operation, rather than subtracting a median filtered DEM. You can perform this operation in QGIS using the Whitebox for Processing plugin (requires QGIS 3) and the TophatTransform tool, which works with several raster data formats (including GeoTIFF files).

enter image description here

Alternatively, a white top-hat transform can be performed in any spatial analysis environment that offers a minimum filter (erosion) and maximum filter (dilation), since the transform is essentially the subtraction of the original DSM from the eroded and subsequently dilated surface.

| improve this answer | |
  • Thank you for this good idea. However once I download Whitebox and try to install it in the initial steps in order to have it listed under option>processing, the white box exe file does not run. So Im basically unable to activate the plugin in QGIS3 with whitebox not running. Also is there an option to use whitebox through R software? I have tried White box before but never got past the .exe file not running problem. – RK4gis May 25 '18 at 9:30
  • @RK4gis The exe is a command line program and is not really intended to be run on its own. For the QGIS plugin, you will need to set up the plugin to see the exe (instructions are on Alex's webpage). You may also run the tools using the wb_runner.py script without the need for QGIS. No, there isn't currently a way to run the tools from R, that I am aware of. – WhiteboxDev May 25 '18 at 12:08

Not the answer you're looking for? Browse other questions tagged or ask your own question.