seedlit / dsm2dtm Goto Github PK
View Code? Open in Web Editor NEWGenerates DTM (Digital Terrain Model) from DSM (Digital Surface Model).
License: MIT License
Generates DTM (Digital Terrain Model) from DSM (Digital Surface Model).
License: MIT License
Cn we use something similar to setup the dependencies easily via conda https://stackoverflow.com/a/59390280/7630458?
As I can see GDAL has a binary available via conda: https://gdal.org/download.html#conda and same goes for rasterio: https://github.com/conda-forge/rasterio-feedstock#installing-rasterio.
This will make it easy for users to be able to start with the package easily also they don't need to manually install GDAL. Let me know your thoughts on this.
Once this is sorted, I would like to contribute to make this package available on conda or pip for easy consumption.
I have been able to run the code and it took my entire day to run, i have low number of processor.
Now I am facing the error which I have attached as an attachment.
Please do respond to it and suggest me so method or modification that i need to do. This is my last resort, I need the DTM for flood modelling. Any insight will be helpful.
def get_raster_resolution(raster_path)
. Like so:def get_raster_resolution(raster_path):
raster = gdal.Open(raster_path)
raster_geotrans = raster.GetGeoTransform()
x_res = raster_geotrans[1]
y_res = -raster_geotrans[5]
prj = raster.GetProjection()
crs = osr.SpatialReference(wkt=prj)
return x_res, y_res, crs
this will render def get_raster_crs(raster_path):
and rasterio unnecessary.
your import will then be:
from osgeo import gdal, osr
def extract_dtm(dsm_path, ground_dem_path, non_ground_dem_path, radius, terrain_slope):
"""
Generates a ground DEM and non-ground DEM raster from the input DSM raster.
Input:
dsm_path: {string} path to the DSM raster
radius: {int} Search radius of kernel in cells.
terrain_slope: {float} average slope of the input terrain
Output:
ground_dem_path: {string} path to the generated ground DEM raster
non_ground_dem_path: {string} path to the generated non-ground DEM raster
"""
cmd = "saga_cmd grid_filter 7 -INPUT {} -RADIUS {} -TERRAINSLOPE {} -GROUND {} -NONGROUND {}".format(
dsm_path, radius, terrain_slope, ground_dem_path, non_ground_dem_path
)
os.system(cmd)
ERROR 4: Attempt to create new tiff file `generated_dtm\temp_files\generated_dtm\temp_files\sample_dsm_ds_slp.tif' failed: No such file or directory
ERROR 1: Unable to create dataset generated_dtm\temp_files\generated_dtm\temp_files\sample_dsm_ds_slp.tif
ERROR 4: generated_dtm\temp_files\generated_dtm\temp_files\sample_dsm_ds_slp.tif: No such file or directory
Traceback (most recent call last):
File "D:/PycharmProjects/pythonProject/dsm2dtm/dsm2dtm-main/dsm2dtm.py", line 359, in
dtm_path = main(dsm_path, out_dir)
File "D:/PycharmProjects/pythonProject/dsm2dtm/dsm2dtm-main/dsm2dtm.py", line 304, in main
avg_slp = int(get_mean(dsm_slp_path))
File "D:/PycharmProjects/pythonProject/dsm2dtm/dsm2dtm-main/dsm2dtm.py", line 55, in get_mean
np_raster = np.array(gdal.Open(raster_path).ReadAsArray())
AttributeError: 'NoneType' object has no attribute 'ReadAsArray'
Hi @seedlit,
I think if you will add tests to package, it will help in people understanding the use case easily. Also, it would help track the development of the package in the future. Here is a good line:
... other developers want to see tests in your software before they take it seriously is yet another reason for you to start writing tests.
-https://docs.djangoproject.com/en/3.2/intro/tutorial05/#tests-make-your-code-more-attractive
Just a small suggestion from my side!
Hai seedlit...!
I have issue on DSM to DTM convertion,I done by using the agisoft metashape software but Cones is Created in buildings edges, i tried to smoothness of cones, By using your code DSM to DTM converted ,it came same as the agisoft ,i need without cones (Please refer the image)
what are the parameters need to change in your code.
I attached the image also for reference..
I hope will get quick response.
Thank you... :)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.