Skip to main content

Terrain and hydrological analysis based on LiDAR-derived digital elevation models (DEM)

Project description

lidar

https://mybinder.org/badge_logo.svg https://binder.pangeo.io/badge.svg https://img.shields.io/pypi/v/lidar.svg https://pepy.tech/badge/lidar https://img.shields.io/conda/vn/conda-forge/lidar.svg https://github.com/giswqs/lidar/workflows/build/badge.svg Documentation Status https://img.shields.io/badge/License-MIT-yellow.svg https://img.shields.io/twitter/follow/giswqs?style=social https://img.shields.io/badge/Donate-Buy%20me%20a%20coffee-yellowgreen.svg

Author: Qiusheng Wu (https://wetlands.io)

lidar is a toolset for terrain and hydrological analysis using digital elevation models (DEMs). It is particularly useful for analyzing high-resolution topographic data, such as DEMs derived from Light Detection and Ranging (LiDAR) data.

Contents

Features

  • Smoothing DEMs using mean, median, and Gaussian filters (see filtering.py)

  • Extracting depressions from DEMs (see filling.py).

  • Filtering out small artifact depressions based on user-specified minimum depression size (see filling.py).

  • Generating refined DEMs with small depressions filled but larger depressions kept intact (see filling.py).

  • Delineating depression nested hierarchy using the level-set method (see slicing.py).

  • Delineating mount nested hierarchy using the level-set method (see mounts.py).

  • Computing topological and geometric properties of depressions, including size, volume, mean depth, maximum depth, lowest elevation, spill elevation, perimeter, major axis length, minor axis length, elongatedness, eccentricity, orientation, and area-bbox-ratio (see slicing.py).

  • Exporting depression properties as a csv file (see slicing.py).

Installation

lidar supports a variety of platforms, including Microsoft Windows, macOS, and Linux operating systems. Note that you will need to have Python 3.x (< 3.9) installed. Python 2.x is not supported. The lidar Python package can be installed using the following command. If you encounter any errors, please check the Dependencies section below. The instruction below assumes that you have installed Anaconda. Open Anaconda Prompt and enter the following commands to create a conda environment and install required packages.

conda create -n py38 python=3.8
conda activate py38
conda install -c conda-forge mamba
mamba install -c conda-forge lidar

If you have installed lidar before and want to upgrade to the latest version, you can use the following command:

pip install lidar -U

Tutorials

Launch the interactive notebook tutorial for the lidar Python package with mybinder.org or binder.pangeo.io now:

https://mybinder.org/badge_logo.svg https://binder.pangeo.io/badge.svg

A Quick Example

import os
import pkg_resources
from lidar import *

# identify the sample data directory of the package
package_name = 'lidar'
data_dir = pkg_resources.resource_filename(package_name, 'data/')

# use the sample dem. Change it to your own dem if needed
in_dem = os.path.join(data_dir, 'dem.tif')
# set output directory. By default, use the temp directory under user's home directory
out_dir = os.path.join(os.path.expanduser("~"), "temp")

# parameters for identifying sinks and delineating nested depressions
min_size = 1000      # minimum number of pixels as a depression
min_depth = 0.5      # minimum depth as a depression
interval = 0.3       # slicing interval for the level-set method
bool_shp = True     # output shapefiles for each individual level

# extracting sinks based on user-defined minimum depression size
out_dem = os.path.join(out_dir, "median.tif")
in_dem = MedianFilter(in_dem, kernel_size=3, out_file=out_dem)
sink_path = ExtractSinks(in_dem, min_size, out_dir)
dep_id_path, dep_level_path = DelineateDepressions(sink_path, min_size, min_depth, interval, out_dir, bool_shp)

print('Results are saved in: {}'.format(out_dir))

Check the example.py for more details.

An Interactive Jupyter Notebook Tutorial

This tutorial can be accessed in three ways:

Launch this tutorial as an interactive Jupyter Notebook on the cloud - https://gishub.org/lidar-cloud.

https://i.imgur.com/aIttPVG.gif

lidar GUI

lidar also provides a Graphical User Interface (GUI), which can be invoked using the following Python script:

import lidar
lidar.gui()
https://i.imgur.com/eSjcSs9.png

Dependencies

lidar’s Python dependencies are listed in its requirements.txt file. In addition, lidar has a C library dependency: GDAL >=1.11.2. How to install GDAL in different operating systems will be explained below. More informaton about GDAL can be found here.

It is highly recommended that you use a Python virtual environment (e.g., conda) to test the lidar package. Please follow the conda user guide to install conda if necessary. Once you have conda installed, you can use Terminal or an Anaconda Prompt to create a Python virtual environment. Check managing Python environment for more information.

Once GDAL has been installed, you can then proceed to install the lidar Python package using the following command:

conda create -n py38 python=3.8
conda activate py38
conda install -c conda-forge gdal
pip install lidar

Linux

Debian-based Linux

The following commands can be used to install GDAL for Debian-based Linux distributions (e.g., Ubuntu, Linux Mint).

sudo add-apt-repository ppa:ubuntugis/ppa
sudo apt-get update
sudo apt-get install gdal-bin libgdal-dev
pip install lidar

If you encounter any compiling errors, try the following commands.

sudo apt-get install --reinstall build-essential
sudo apt-get install python3-dev
pip install wheel
Pacman-based Linux

The following commands can be used to install GDAL for Pacman-based Linux distributions (e.g., Arch Linux, Manjaro). You might need to use sudo if you encounter permission errors.

sudo pacman -S yaourt --noconfirm
yaourt -S gdal --noconfirm
yaourt -S python-gdal --noconfirm
pip install lidar

MacOS X

For a Homebrew based Python environment, do the following.

brew update
brew install gdal

Alternatively, you can install GDAL binaries from kyngchaos. You will then need to add the installed location /Library/Frameworks/GDAL.framework/Programs to your system path.

Windows

The instruction below assumes that you have installed Anaconda. Open Anaconda Prompt and enter the following commands to create a conda environment and install required packages

conda create -n py38 python=3.8
conda activate py38
conda install -c conda-forge gdal
pip install richdem
pip install lidar

When installing the richdem package, if you encounter an error saying ‘Microsoft Visual C++ 14.0 is required’, please follow the steps below to fix the error and reinstall richdem. More infomration can be found at this link Fix Python 3 on Windows error - Microsoft Visual C++ 14.0 is required.

  • Download Microsoft Build Tools for Visual Studio 2017

  • Double click to install the downloaded installer - Microsoft Build Tools for Visual Studio 2017.

  • Open Microsoft Build Tools for Visual Studio 2017

  • Select Workloads –> Visual C++ build tools and click the install button

Examples

The images below show working examples of the level set method for delineating nested depressions in the Cottonwood Lake Study Area (CLSA), North Dakota. More test datasets (e.g., the Pipestem watershed in the Prairie Pothole Region of North Dakota) can be downloaded from http://gishub.org/2018-JAWRA-Data

The following example was conducted on a 64-bit Linux machine with a quad-core Intel i7-7700 CPU and 16 GB RAM. The average running time of the algorithm for this DEM was 0.75 seconds.

https://wetlands.io/file/images/CLSA_DEM.jpg https://wetlands.io/file/images/CLSA_Result.jpg https://wetlands.io/file/images/CLSA_Table.jpg

References

The level-set algorithm in the lidar package has been published in the following article:

  • Wu, Q., Lane, C.R., Wang, L., Vanderhoof, M.K., Christensen, J.R., & Liu, H. (2019). Efficient Delineation of Nested Depression Hierarchy in Digital Elevation Models for Hydrological Analysis Using Level-Set Method. Journal of the American Water Resources Association. DOI: 10.1111/1752-1688.12689 (preprint)

Applications of the level-set and contour-tree methods for feature extraction from LiDAR data:

  • Wu, Q., & Lane, C.R. (2017). Delineating wetland catchments and modeling hydrologic connectivity using LiDAR data and aerial imagery. Hydrology and Earth System Sciences. 21: 3579-3595. DOI: 10.5194/hess-21-3579-2017

  • Wu, Q., Deng, C., & Chen, Z. (2016). Automated delineation of karst sinkholes from LiDAR-derived digital elevation models. Geomorphology. 266: 1-10. DOI: 10.1016/j.geomorph.2016.05.006

  • Wu, Q., Su, H., Sherman, D.J., Liu, H., Wozencraft, J.M., Yu, B., & Chen, Z. (2016). A graph-based approach for assessing storm-induced coastal changes. International Journal of Remote Sensing. 37:4854-4873. DOI: 10.1080/01431161.2016.1225180

  • Wu, Q., & Lane, C.R. (2016). Delineation and quantification of wetland depressions in the Prairie Pothole Region of North Dakota. Wetlands. 36(2):215–227. DOI: 10.1007/s13157-015-0731-6

  • Wu, Q., Liu, H., Wang, S., Yu, B., Beck, R., & Hinkel, K. (2015). A localized contour tree method for deriving geometric and topological properties of complex surface depressions based on high-resolution topographic data. International Journal of Geographical Information Science. 29(12): 2041-2060. DOI: 10.1080/13658816.2015.1038719

  • Wu, Q., Lane, C.R., & Liu, H. (2014). An effective method for detecting potential woodland vernal pools using high-resolution LiDAR data and aerial imagery. Remote Sensing. 6(11):11444-11467. DOI: 10.3390/rs61111444

Reporting Bugs

Report bugs at https://github.com/giswqs/lidar/issues.

If you are reporting a bug, please include:

  • Your operating system name and version.

  • Any details about your local setup that might be helpful in troubleshooting.

  • Detailed steps to reproduce the bug.

Credits

History

0.2.0 (2018-09-16)

0.1.6 (2018-05-21)

0.1.5 (2018-05-16)

0.1.3 (2018-05-15)

0.1.0 (2018-05-14)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lidar-0.5.1.tar.gz (1.1 MB view details)

Uploaded Source

Built Distribution

lidar-0.5.1-py2.py3-none-any.whl (1.1 MB view details)

Uploaded Python 2 Python 3

File details

Details for the file lidar-0.5.1.tar.gz.

File metadata

  • Download URL: lidar-0.5.1.tar.gz
  • Upload date:
  • Size: 1.1 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.54.0 CPython/3.9.0

File hashes

Hashes for lidar-0.5.1.tar.gz
Algorithm Hash digest
SHA256 69ac99fd5ba1190df4fdd541dc2608ee958057948fcf3c93121c1a2e1da0f65e
MD5 f3b4e6d9322ea0313fea1efcb8ce1c6a
BLAKE2b-256 cfd440bfe76b5fccd56dfabb4dd291e43faecf60d6448f7375718fd69a5db78e

See more details on using hashes here.

File details

Details for the file lidar-0.5.1-py2.py3-none-any.whl.

File metadata

  • Download URL: lidar-0.5.1-py2.py3-none-any.whl
  • Upload date:
  • Size: 1.1 MB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.54.0 CPython/3.9.0

File hashes

Hashes for lidar-0.5.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 8360b592fac12b44904f886e8061b9fa9b883107e8fee1c44f53caa64bfb4100
MD5 9fef572e644d5d0e97716c1d55653100
BLAKE2b-256 17c73c7cb4b5ae5be63e4e41bd711313a2536f22a859b68acef1b9707d875496

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page