I have some DSM GeoTIFF files and I want to convert them to DTM and then obtain nDSM by subtracting DTM from DSM.
Is there any way to do it?
I want to apply this to several different DSMs so it's best if I find an automatic code or bash tool.
dempythonr
I have some DSM GeoTIFF files and I want to convert them to DTM and then obtain nDSM by subtracting DTM from DSM.
Is there any way to do it?
I want to apply this to several different DSMs so it's best if I find an automatic code or bash tool.
Best Answer
So I found the answer myself.
This is the pipeline:
There is LAStools in which there is a command txt2las. So if I have a txt file which contains XYZ values in each row of the file, then I can use this command to obtain LAS.
So first I have to drag XYZ values from my Geotiff image to a text file. To do this I used answers from this question. I extracted x and y values from the method there and z values from the DSM itself.
Now that I have a text file containing xyz values, I can run the command I specified earlier.
here we have a LAS file. To convert it to DTM I used lidR library in R. I used the function classify_ground to classify the ground points and then I used grid_terrain to obtain DTM.
At last subtracted DTM from DSM to get nDSM. here is the result.
The resulted nDSM is exactly what I wanted.
I hope this answer helps the next person with same question.