08 whitebox
In [ ]:
Copied!
# !pip install leafmap
# !pip install leafmap
In [ ]:
Copied!
import os
import leafmap
import os
import leafmap
Download a sample DEM dataset.
In [ ]:
Copied!
out_dir = os.getcwd()
dem = os.path.join(out_dir, "dem.tif")
dem_url = (
"https://drive.google.com/file/d/1vRkAWQYsLWCi6vcTMk8vLxoXMFbdMFn8/view?usp=sharing"
)
leafmap.download_file(dem_url, "dem.tif", unzip=False)
out_dir = os.getcwd()
dem = os.path.join(out_dir, "dem.tif")
dem_url = (
"https://drive.google.com/file/d/1vRkAWQYsLWCi6vcTMk8vLxoXMFbdMFn8/view?usp=sharing"
)
leafmap.download_file(dem_url, "dem.tif", unzip=False)
Create an interactive map.
In [ ]:
Copied!
Map = leafmap.Map()
Map
Map = leafmap.Map()
Map
Use the built-in toolbox to perform geospatial analysis. For example, you can perform depression filling using the sample DEM dataset downloaded in the above step.
Display the toolbox using the default mode.
In [ ]:
Copied!
leafmap.whiteboxgui()
leafmap.whiteboxgui()
Display the toolbox using the collapsible tree mode. Note that the tree mode does not support Google Colab.
In [ ]:
Copied!
leafmap.whiteboxgui(tree=True)
leafmap.whiteboxgui(tree=True)
Perform geospatial analysis using the whitebox package.
In [ ]:
Copied!
import os
import pkg_resources
import os
import pkg_resources
In [ ]:
Copied!
wbt = leafmap.WhiteboxTools()
wbt.verbose = False
wbt = leafmap.WhiteboxTools()
wbt.verbose = False
In [ ]:
Copied!
# identify the sample data directory of the package
data_dir = os.path.dirname(pkg_resources.resource_filename("whitebox", "testdata/"))
wbt.set_working_dir(data_dir)
wbt.feature_preserving_smoothing("DEM.tif", "smoothed.tif", filter=9)
wbt.breach_depressions("smoothed.tif", "breached.tif")
# identify the sample data directory of the package
data_dir = os.path.dirname(pkg_resources.resource_filename("whitebox", "testdata/"))
wbt.set_working_dir(data_dir)
wbt.feature_preserving_smoothing("DEM.tif", "smoothed.tif", filter=9)
wbt.breach_depressions("smoothed.tif", "breached.tif")