<jupyter_start><jupyter_text>[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://githubtocolab.com/giswqs/leafmap/blob/master/examples/notebooks/08_whitebox.ipynb)[![image](https://binder.pangeo.io/badge_logo.svg)](https://gishub.org/leafmap-pangeo)**Using WhiteboxTools with leafmap**Uncomment the following line to install [leafmap](https://leafmap.org) if needed.<jupyter_code># !pip install leafmap
import os
import leafmap<jupyter_output><empty_output><jupyter_text>Download a sample DEM dataset.<jupyter_code>out_dir = os.path.expanduser('~/Downloads')
dem = os.path.join(out_dir, 'dem.tif')

if not os.path.exists(dem):
    dem_url = 'https://drive.google.com/file/d/1vRkAWQYsLWCi6vcTMk8vLxoXMFbdMFn8/view?usp=sharing'
    leafmap.download_from_gdrive(dem_url, 'dem.tif', out_dir, unzip=False)<jupyter_output><empty_output><jupyter_text>Create an interactive map.<jupyter_code>Map = leafmap.Map()
Map<jupyter_output><empty_output><jupyter_text>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. ![](https://i.imgur.com/KGHly63.png) Display the toolbox using the default mode.<jupyter_code>leafmap.whiteboxgui()<jupyter_output><empty_output><jupyter_text>Display the toolbox using the collapsible tree mode. Note that the tree mode does not support Google Colab.<jupyter_code>leafmap.whiteboxgui(tree=True)<jupyter_output><empty_output><jupyter_text>Perform geospatial analysis using the [whitebox](https://github.com/giswqs/whitebox-python) package.<jupyter_code>import os
import pkg_resources
wbt = leafmap.WhiteboxTools()
wbt.verbose = True
# 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")<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12686567164179105, 'fraction_numerical': 0.004477611940298508, 'mean_word_length': 7.8201754385964914, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 25, 'https://': 8, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '210886', 'license': 'MIT', 'n_tokens_mistral': 735, 'n_tokens_neox': 703, 'n_words': 120, 'path': 'examples/notebooks/08_whitebox.ipynb', 'repo_name': 'ajstewartlang/leafmap', 'size': '2010'}