jblindsay / whitebox-tools

An advanced geospatial data analysis platform
https://www.whiteboxgeo.com/
MIT License
967 stars 161 forks source link

WhiteboxWorkflows: Filters based on DEM reading not working #406

Open Laurakhumsup opened 6 months ago

Laurakhumsup commented 6 months ago

Hi, I'm coding in python and would like to use the feature preserving smoothing filter on my DEM, previously created by idw interpolation. I do not get any error message while running my code but as both hillshade and hillshade smoothed rasters are the same, I suppose the smoothing filter didn't work.

There is my code:

Data reading/writting

AOI_1_DEM_IDW_filled = data_path + 'AOI_1_DEM_TIN.tif' AOI_1_DEM_IDW_smoothed = data_path + 'AOI_1_DEM_IDW_smoothed.tif'

Feature preserving smoothing

wbt.feature_preserving_smoothing(dem=AOI_1_DEM_IDW_filled, output=AOI_1_DEM_IDW_smoothed, filter=21, norm_diff=25, num_iter=5 )

Data reading/writting

AOI_1_DEM_IDW_smoothed = data_path + 'AOI_1_DEM_IDW_smoothed.tif' AOI_1_hillshade_smoothed = data_path + 'AOI_1_hillshade_smoothed.tif' AOI_1_multi_hillshade_smoothed = data_path + 'AOI_1_multi_hillshade_smoothed.tif'

Multidirectional Hillshade (Four-direction mode)

wbt.multidirectional_hillshade(dem=AOI_1_DEM_IDW_smoothed, output=AOI_1_multi_hillshade_smoothed, full_mode=False)

wbt.hillshade(dem=AOI_1_DEM_IDW_smoothed, output=AOI_1_hillshade_smoothed)

Read the raster using rioxarray

hillshade_smoothed = rxr.open_rasterio(AOI_1_hillshade_smoothed, masked=True)

View the raster

ep.plot_bands(arr=hillshade_smoothed, cmap="binary", figsize=(8, 8), title="Lidar Smoothed Hillshade")

plt.show();

I should specify that when using curvature filters, I was using the same DEM and the results were showing no features (0 value everywhere), so the problem might come from reading the DEM.

Thanks for your help :)