Comments (6)
saga_cmd issue had been solved, after add the saga_cmd.exe path.
Then, I try the tests.py.
Traceback (most recent call last):
File "D:/PycharmProjects/pythonProject/dsm2dtm/dsm2dtm-main/tests.py", line 43, in
assert os.path.isfile(diff_raster_path)
AssertionError
GDAL was installed by "conda install gdal==3.4.3"
Next, I need to check how gdal_calc.py work.
def subtract_rasters(rasterA_path, rasterB_path, out_path, no_data_value=-99999.0):
cmd = 'gdal_calc.py -A {} -B {} --outfile {} --NoDataValue={} --calc="A-B"'.format(
rasterA_path, rasterB_path, out_path, no_data_value
)
os.system(cmd)
from dsm2dtm.
I verify "/"to"\", then the dsm2dtm.py work well
Thank you, nice repo!
Generate DTM
# STEP 1: Generate slope raster from dsm to get average slope value
dsm_name = dsm_path.split("\\")[-1].split(".")[0]
dsm_slp_path = os.path.join(temp_dir, dsm_name + "_slp.tif")
generate_slope_raster(dsm_path, dsm_slp_path)
avg_slp = int(get_mean(dsm_slp_path))
total execution time: 0 milliseconds (less than 1 millisecond)
[Close Gaps] Execution succeeded (less than 1 millisecond)
Saving grid: generated_dtm\temp_files\sample_dsm_ds_dtm.sdat...
100%
okay
######### DTM generated at: generated_dtm\sample_dsm_ds_dtm.tif
from dsm2dtm.
try tests.py
0...10...20...30...40...50...60...70...80...90...100 - done.
'saga_cmd' �����ڲ����ⲿ���Ҳ���ǿ����еij���
���������ļ���
Traceback (most recent call last):
File "D:/PycharmProjects/pythonProject/dsm2dtm/dsm2dtm-main/tests.py", line 34, in
assert os.path.isfile(ground_dem_path)
AssertionError
from dsm2dtm.
ground_dem_filtered_path = 'XXX\dsm2dtm-main\data\sample_dsm_ds_ground_filtered.tif'
there is no such file
from dsm2dtm.
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)
I try the tests.py
this function can not create the ground DEM raster & non-ground DEM raster files
I consider that I should deal with the saga_cmd on win platform
from dsm2dtm.
I verify the cmd str, add 'python' in thf front, and copy the gdal_calc.py to the local root.
def subtract_rasters(rasterA_path, rasterB_path, out_path, no_data_value=-99999.0):
cmd = 'python gdal_calc.py -A {} -B {} --outfile {} --NoDataValue={} --calc="A-B"'.format(
rasterA_path, rasterB_path, out_path, no_data_value
)
os.system(cmd)
Now the tests.py work
total execution time: 0 milliseconds (less than 1 millisecond)
[Close Gaps] Execution succeeded (less than 1 millisecond)
Saving grid: test_results\temp_files\sample_dsm_dtm.sdat...
100%
okay
All tests passed!
But, when I run the dtm2dsm.py, there are double 'generated_dtm\temp_files' in the raster_path str.
raster_path = 'generated_dtm\temp_files\generated_dtm\temp_files\sample_dsm_ds_slp.tif'
from dsm2dtm.
Related Issues (6)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dsm2dtm.