Package: landspy
landspyLandscape analysis with Python1. PurposeThe landspy library provides some useful Python classes and functions for topographic analysis, drainage network extraction and computation of important geomorphic indices from Digital Elevation Models (DEMs). The main goal of landspy is to provide a simple way to compute geomorphic indices for those researchers who are not familiar with complex computational techniques. This library aims to pave the way for tectonic geomorphologists who do not have deep programming skills, but who can play a very relevant role in the interpretation of these analyses in terms of their relationship with geology, tectonics and associated hazards.This library is constantly growing, and we will include more analysis and functions in future versions.2. InstallationThe library can be installed via pip viapipor conda (we recommend to install viaconda-forge) on Linux, Mac, and Windows.pip installationInstall the package by typing the following command in a command terminal:pip install landspyWhen installed via pip, it is recommended to haveGDALpreviously installed in our environment. It will be necessary to have libgdal and its development headers installed if pip is expected to do a source build because no wheel is available for your specified platform and Python version.To install the latest development version via pip, see ourgithub project page.conda installation (recommended)We can install landspy viaconda-forge.
Once you have Anaconda or Miniconda installed, you should be able to install GDAL with:conda install -c conda-forge landspyQGIS installationWhen installinglandspyto use inside QGIS, we will use the pip installation. As most of the requirements will be already available in the Python QGIS environment, follow these steps:Open OSGeo4W shell (packed with QGIS in the start menu)If running a QGIS version lower than 3.18 (not needed for later versions). Type:py3_envInstall via pip by typing:pip install landspy3. RequirementsAll dependencies should be installed along with landspy (See GDAL note for pip instalation).GDALNumPy >= 1.14.5SciPy >= 1.1.0scikit-image >= 1.0.0matplotlib >= 3.0.04. CitationWe are preparing aPérez-Peña et al.:
Lansdpy, a open-source library for landscape analysis in Python and QGIS.
[In preparation]5. Tutorials and ExamplesTo get an overview of howlandspyworks, we offer some tutorials to perform some of the most common tasks that can be done with it.Extraction of a drainage networkCalulation of Chi-maps and ksn valuesPlot single channel profilesCreate channels from a polyline shapefileCreate channels from a drainage basinCreate hypsometric curvesThe associated python scripts are provided in thedocsfolder.6. ExamplesCreation of a Chi Map from a Digital Elevation ModelThis is an example of how to generate a Chi Map in vector format from a DEM.fromlandspyimportDEM,Flow,Network# Load the DEM and create the Flow and the Networkdem=DEM("data/jebja30.tif")fd=Flow(dem)# Create a Network object with a threshold of 1500 cells and reference m/n of 0.45net=Network(fd,1500,thetaref=0.45)# Create a Chi Map in vector format for segments of 250 and 500 mnet.chiShapefile("data/chiMap_250.shp",250)net.chiShapefile("data/chiMap_500.shp",500)Analysis of different values of m/n for a basinThis is an example we analyze the best m/n value for Chi anlysis in a sample small basinfromlandspyimportGrid,DEM,Flow,Network,BNetworkimportmatplotlib.pyplotasplt# Load the DEM and create the Flow and the Networkdem=DEM("data/jebja30.tif")fd=Flow(dem)# Create a Network object with a threshold of 1500 cells and reference m/n of 0.45net=Network(fd,1500,thetaref=0.45)# Load the Basinsbasins=Grid("data/basins")# Generate the BNetwork object for the basin with id=2bnet=BNetwork(net,basins,bid=2)# Check different m/n values for chi analysismn_vals=[0.25,0.3,0.35,0.4,0.45,0.5]fig=plt.figure(figsize=(17,10))forn,mninenumerate(mn_vals):bnet.calculateChi(mn)ax=fig.add_subplot(2,3,n+1)bnet.chiPlot(ax)ax.set_title("Chi plot (m/n ={})".format(mn))ax.set_xlabel("$\\chi$ (m)")ax.set_ylabel("Elevation (m)")plt.tight_layout()7. ContactYou can contact me viageolovic@gmail.comvperez@ugr.es.8. LicenseMIT License© 2022