### Install LISEM Python Package Source: https://lisemmodel.com/docs/usingpython Install the LISEM Python package using pip. Ensure all required dependencies are met. ```bash pip install lisem_..._.whl ``` -------------------------------- ### Recursive Fibonacci Function Example Source: https://lisemmodel.com/docs/usingscripting A C-style function definition example, specifically a recursive implementation of the Fibonacci sequence. Demonstrates function return types and arguments. ```angelscript int fibonacci(int n) { if(n <= 1) { return n; } else { return fibonacci(n-1) + fibonacci(n-2); } } ``` -------------------------------- ### Initiate Automated Calibration Source: https://lisemmodel.com/docs/calibration Starts the automated calibration process using gradient descent. Provide initial parameter values, positivity constraints, a custom error function, and step sizes. ```lisemscript OptimizeCustom({1.0,1.0},{true,true},@Calibrate,0.01,0.05); ``` -------------------------------- ### Converting Raster to Vector Source: https://lisemmodel.com/docs/warping Convert a raster dataset into a vector dataset. This example vectorizes a channel width raster, using the 'width' attribute. ```csharp rivers.shp = Vectorize(channelwidth.map,"width"); ``` -------------------------------- ### Conditional If/Else Statement Source: https://lisemmodel.com/docs A basic example of an if/else statement in LISEM scripting. The code within the 'if' block executes if the condition is true; otherwise, the 'else' block executes. ```angelscript void main() { if(true) { Print("This is printed") }else { Print("This is not printed") } } ``` -------------------------------- ### Download Soil Classification Data Source: https://lisemmodel.com/docs/webdata Downloads soil classification data from SOILGRIDS using a WCS service with a GET request. The downloaded GeoTIFF is converted to a map object. ```lisemscript soilclass.tif = ToMap(Download("http://maps.isric.org/mapserv?map=/map/wrb.map&SERVICE=WCS&VERSION=1.0.0&REQUEST=GetCoverage&coverage=MostProbable&CRS=EPSG:3978&BBOX=-2200000,-712631,3072800,3840000&WIDTH=3199&HEIGHT=2833&FORMAT=GTiff")); ``` -------------------------------- ### Recursive Fibonacci Function Source: https://lisemmodel.com/docs An example of a recursive function definition in LISEM scripting, calculating the nth Fibonacci number. Functions follow a C-style format. ```angelscript int fibonacci(int n) { if(n <= 1) { return n; }else { return fibonacci(n-1) + fibonacci(n-2); } } ``` -------------------------------- ### Cutting Raster Subsets Source: https://lisemmodel.com/docs/warping Extract a subset of a raster dataset using either a defined Region or by getting the region from a shapefile. ```csharp section_custom.tif = RasterCut(dem.tif,Region(0,1.0,0.0,1.0)); section.tif = RasterCut(dem.tif,GetRegion(shape.shp)); ``` -------------------------------- ### Setting CRS for Raster Layers Source: https://lisemmodel.com/docs/warping Set the Coordinate Reference System (CRS) for a raster layer by getting it from another file, using WGS84 UTM, or an EPSG code. ```csharp test.tif = SetCRS(tes.tif,GetCRS(test2.tif)); //get CRS from other file test.tif = SetCRS(tes.tif,GeoProjectionFromWGS84UTM(30,true)); //use WGS84 UTM 30 N test.tif = SetCRS(tes.tif,GeoProjectionFromEPSG(4326)); //use WGS84 (EPSG code 4326) ``` -------------------------------- ### Custom Calibration Error Function Source: https://lisemmodel.com/docs/calibration Defines a custom function to calculate the error for the calibration process. This example runs the LISEM model, loads predicted and actual data, and returns an error value based on MapContinuousCohensKappa. ```lisemscript double Calibrate(array params) { RunModel("run/Couli_AutoCalib.run","Internal Friction Angle_cal_mult="+ToString(params[0])+"|" + "Cohesion Bottom_cal_mult="+ToString(params[1])); Map impact = LoadMap("res/safetyfactor.map"); Map inventory = 1.0-LoadMap("maps/inventory.tif"); double errorval = MapContinuousCohensKappa(inventory,impact,1.0); Print("Running model with ifa= " + ToString(params[0]) +"& coh= " + ToString(params[1]) + " score = " + ToString(1.0-errorval)); return (1.0-errorval); } ``` -------------------------------- ### Logistic Binary Classification for Susceptibility Source: https://lisemmodel.com/docs/classification Performs a logistic binary classification, for example, for landslide susceptibility, using normalized slope, DEM, and PGA maps. ```plaintext MathExpression expr = MapLogisticRegression({MapNormalize(slope.map),MapNormalize(dem.map),MapNormalize(pga.map)},training.map); Print(expr.GetExpression()); ``` -------------------------------- ### Basic Script Structure Source: https://lisemmodel.com/docs A simple script demonstrating basic map calculations and function calls. Scripts must include a void main() function as the entry point. ```angelscript void main() { a.tif = b.tif + 2.0; slope.tif = Slope(dem.tif); angle.tif = Sin(Atan(Slope(dem.tif))); a.map = MapMaximum(angle.tif) } ``` -------------------------------- ### Simulate Time Steps for Water Flow Source: https://lisemmodel.com/docs/dynamicmodels Sets up a loop to simulate water flow over a specified period with defined time steps. It prints a message every minute of simulated time. ```csharp void main() { Map dem = dem.tif; //we will simulate 1 hour, with timesteps of 6 seconds. int n_steps = 60 *60/6; //nunmber of timesteps float t = 0.0; //time in seconds float dt = 6.0; //timestep in seconds for(int i = 0; i < n_steps; i++) { t = t + 6; //message the user if we are finished another minute if( floor(t)%60 == 0) { Print("We are now at minute : " + ToString(t/60)); } } } ``` -------------------------------- ### Simple Water-Flow Simulation using FlowDynamic Source: https://lisemmodel.com/docs/flooding This script demonstrates a basic flood simulation using the FlowDynamic function. It requires elevation, initial water height, and Manning's N maps. The simulation runs for a specified number of timesteps, storing flow height and velocity periodically. ```void void main() { Map dem = dem.map; Map whinitial = initialwaterheight.map; Map n= dem * 0.0 + 0.1; //homogeneous mannings n of 0.1 Print("Create Initial Properties"); //a list with {height, x-velocity, y-velocity} array flowprops = {whinitial,whinitial * 0.0,whinitial*0.0}; Print("Add Layers"); UILayer l = AddViewLayer( whinitial, "elevation",true); for(int i = 0; i < 5000; i++) { flowprops = FlowDynamic(dem, n,flowprops[0],flowprops[1],flowprops[2],0.1); ReplaceViewLayer(l, flowprops[0]); //every 50 timesteps, store the flow height and velocity if( i % 50== 0) { whelev.tif = dem+flowprops[0]; whvel.tif = sqrt(flowprops[2] *flowprops[2] + flowprops[1] *flowprops[1]) ; } Print("Timestep : " + ToString(i)); } } ``` -------------------------------- ### Scripting with File Loading and Loops Source: https://lisemmodel.com/docs This script shows how to load maps from files (relative and absolute paths) and process them within a loop. It also includes comments and defines a custom function. ```angelscript //this is a comment //here the main() function is defined //the entry point void main() { a.map = b.map; Map a = a.map; //Load… functions take a path relative to the working directory Map b = LoadMap("b.map") //The Load.. functions have a variant that takes an absolute path Shapes s = LoadShapesAbsPath("C:/s.shp") //this loop runs for 100 iterations for(int i = 0; i < 100; i++) { b = AddToB(b); } } //define another function call AddToB, it takes 1 argument of type Map Map AddToB(Map b) { b += c.map; return b; } ``` -------------------------------- ### Main Function for Calibration Source: https://lisemmodel.com/docs/calibration The main function that initiates the calibration process by calling OptimizeCustom with specific parameters. ```lisemscript void main() { OptimizeCustom({1.0,1.0},{true,true},@Calibrate,0.01,0.05); } ``` -------------------------------- ### Simulate Rainfall and Water Flow Source: https://lisemmodel.com/docs/dynamicmodels Simulates rainfall for the first half hour and applies a dynamic flow approximation using the FlowDynamic function. Results are saved to 'h_final.tif'. ```csharp void main() { Map dem = dem.tif; //use the elevation model to create an empty map of identical size. //this will be the water height, flow velocity in x and y direction array flow = {dem * 0.0,dem * 0.0,dem * 0.0}; //we will simulate 1 hour, with timesteps of 6 seconds. int n_steps = 60 *60/6; //nunmber of timesteps float t = 0.0; //time in seconds float dt = 6.0; //timestep in seconds for(int i = 0; i < n_steps; i++) { t = t + dt; if(t < 30*60) { //convert to meter/hour flow[0] += 50 * dt * 0.001 / (60*60); } //make a timestep of 6 second with the dynamic flow approximation //the resutls overwrites the old data flow = FlowDynamic(dem,dem*0.0 + 0.1,flow[0],flow[1],flow[2],6,0.2); //message the user if we are finished another minute if( floor(t)%60 == 0) { Print("We are now at minute : " + ToString(t/60)); } //save the model results h_final.tif = flow[0]; } } ``` -------------------------------- ### Define a Class in AngelScript Source: https://lisemmodel.com/docs Demonstrates the C-style syntax for defining a class with member variables and methods. Local variables can shadow class properties, requiring explicit access using 'this'. ```angelscript // The class declaration class MyClass { // A class method void DoSomething() { // The class properties can be accessed directly a *= 2; // The declaration of a local variable may hide class properties int b = 42; // In this case the class property have to be accessed explicitly this.b = b; } // Class properties int a; int b; } ``` -------------------------------- ### Calibrate LISEM Model Parameters Source: https://lisemmodel.com/docs/lisemcalibration This script calibrates LISEM simulations for cohesion and internal friction angle. It defines an error function and uses OptimizeCustom to find optimal parameters. Ensure the run file and map paths are correct. ```C++ //this function is the error function. It takes a list of parameters (2) and returns the model error double Calibrate(array params) { //run the LISEM model, by calling a run file within the working directory. //The second argument is a string containing the options is the following format: "name=value|name2=value2" //the names can be found within the run-files. Add _cal_mult to a name to get the calibration multiplier. //Here, we set the calibration multiplier for internal friction angle and cohesion. RunModel("run/Couli_AutoCalib.run","Internal Friction Angle_cal_mult="+ToString(params[0])+"|" + "Cohesion Bottom_cal_mult="+ToString(params[1])); //load the impact and inventory maps Map impact = LoadMap("res/safetyfactor.map"); Map inventory = 1.0-LoadMap("maps/inventory.tif"); //calculate error value through Cohens Kappa double errorval = MapContinuousCohensKappa(inventory,impact,1.0); //print info to output window Print("Running model with ifa= " + ToString(params[0]) +"& coh= " + ToString(params[1]) + " score = " + ToString(1.0-errorval)); //actual error is 1.0- Cohens Kappa return (1.0-errorval); } void main() { //Optimize custom will minimize the error for a function //the function Calibrate is defined above //we start with two parameters of value 1.0 that must be positive. //finite step size = 0.01, gradient step size = 0.05 //gradient step size might need to be lowered for stable convergence. OptimizeCustom({1.0,1.0},{true,true},@Calibrate,0.01,0.05); } ``` -------------------------------- ### Apply Window Average Filter (60) Source: https://lisemmodel.com/docs/filters Applies a window average filter with a specified window size (60) to a dataset for smoothing. ```lisem dem_lidar_av.map = WindowAverage(dem_lidar.map,60) ``` -------------------------------- ### Basic Conditional Logic in a Script Source: https://lisemmodel.com/docs/usingscripting Demonstrates the use of if/else statements for conditional execution within a LISEM script. The Print function outputs messages. ```angelscript void main() { if(true) { Print("This is printed") } } ``` -------------------------------- ### Visualize Water Flow Simulation Source: https://lisemmodel.com/docs/dynamicmodels Adds a hillshade background and a dynamic water height layer to the map viewer. The water height layer is updated in each time step during the simulation. ```csharp void main() { Map dem = dem.tif; //use the elevation model to create an empty map of identical size. //this will be the water height, flow velocity in x and y direction array flow = {dem * 0.0,dem * 0.0,dem * 0.0}; //add view layers AddViewLayer(HillShade(dem),"hillshade"); UILayer hlay = AddViewLayer(flow[0],"flow height (m)"); //we will simulate 1 hour, with timesteps of 6 seconds. int n_steps = 60 *60/6; //nunmber of timesteps float t = 0.0; //time in seconds float dt = 6.0; //timestep in seconds for(int i = 0; i < n_steps; i++) { t = t + dt; if(t < 30*60) { //convert to meter/hour flow[0] += 50 * dt * 0.001 / (60*60); } //make a timestep of 6 second with the dynamic flow approximation //the resutls overwrites the old data flow = FlowDynamic(dem,dem*0.0 + 0.1,flow[0],flow[1],flow[2],6,0.2); //message the user if we are finished another minute if( floor(t)%60 == 0) { Print("We are now at minute : " + ToString(t/60)); } //update map viewer ReplaceViewLayer(hlay,flow[0]); //save the model results h_final.tif = flow[0]; } } ``` -------------------------------- ### Loading a List of Maps from a GeoTIFF Source: https://lisemmodel.com/docs Demonstrates how to load multiple map bands from a GeoTIFF file into an Array of Maps. The Array type is templated, specifying the type of data it holds. ```angelscript Array bands = LoadMapBandList(spectral.tif) ``` -------------------------------- ### Create Empty Map for Training Data Source: https://lisemmodel.com/docs/classification Initializes an empty map with the same dimensions as the input raster, intended for storing training data for supervised classification. ```plaintext training.tif = result.tif[0] * 0.0; ``` -------------------------------- ### Benchmark GPU vs CPU Raster Calculation Source: https://lisemmodel.com/docs/gpu This snippet benchmarks a simple GPU raster calculation against its CPU equivalent. It demonstrates uploading data to the GPU, performing operations, and downloading results. Note that data transfer between CPU and GPU can impact performance. ```C++ void main() { //first create a temporary empty gpu map //this will initialize all the gpu-side code, but this is done only once GpuMap temp = GpuMap(); //now we do the benchmark GPUMap m = ToGPU(dem_lidar_5ml.map); double t = GetAppTime(); GPUMap m2 = pow(sqrt(sqrt(m)),2.0); Print("GPU TIME " + ToString(GetAppTime() - t)); test.map = ToCPU(m2); Map mc = dem_lidar_5ml.map; t = GetAppTime(); Map mc2 = sqrt(sqrt(mc)); Print("CPU TIME " + ToString(GetAppTime() - t)); } ``` -------------------------------- ### Create Multi-band Raster File Source: https://lisemmodel.com/docs/datamanipulation Combines multiple raster layers into a single multi-band raster file. ```angelscript layers.tif = {dem.map,slope.map,WindowAverage(flux.map,100)) ``` -------------------------------- ### Execute Geo-spatial Algorithms Source: https://lisemmodel.com/docs/datamanipulation Applies advanced geo-spatial algorithms like flux accumulation using input maps. ```angelscript flux.map = Accuflux(ldd.map,Slope.map) ``` -------------------------------- ### Estimate Channel Width and Depth Source: https://lisemmodel.com/docs/elevationdata Estimates channel width and depth using global relationships based on flow accumulation, converting cell size to kilometers. ```python channelwidth.tif = 9.68*(accuflux.tif/1e6)**0.32 channeldepth.tif = 11.3*(accuflux.tif/1e6)**0.083 ``` -------------------------------- ### Calculate 2D Flow Accumulation Source: https://lisemmodel.com/docs/elevationdata Calculates 2D flow accumulation, potentially considering different flow dynamics. ```python accuflux2d.tif = Accuflux2D(dem.map,dem.map * 0.0 + 1.0,dem.map * 0.0,0.3,1.0) ``` -------------------------------- ### Load and Convert Map Data Source: https://lisemmodel.com/docs/datamanipulation Loads a map in one format and saves it to another, like ASC to GeoTIFF. ```angelscript dem.tif = dem.asc ``` -------------------------------- ### Map Operations with Advanced Operators Source: https://lisemmodel.com/docs Illustrates the use of advanced operators for map manipulation, including bitwise AND (&), right shift (>>), and the custom equality operator (.eq). ```angelscript Conditional.tif = MapIf( (a.map >> b.map) & (c.tif.eq(d.tif)), iftrue.tif, iffalse.tif) ``` -------------------------------- ### Apply Machine Learning Model for Elevation Data Source: https://lisemmodel.com/docs/downloads Use this code to apply a machine learning model to an elevation file for creating high-resolution elevation data. Replace 'model.onnx' with the desired model file. ```python hr.tif = ApplyMLModel({lr.tif},"model.onnx",32,32,{0,3,1,2}); ``` -------------------------------- ### Highlight Filled Depressions Source: https://lisemmodel.com/docs/elevationdata Calculates the difference between the original DEM and the depression-filled DEM to highlight changes. ```python dif.tif = dem_fix.tif - dem.tif ``` -------------------------------- ### Download OpenStreetMap Data via POST Source: https://lisemmodel.com/docs/webdata Downloads OpenStreetMap data using a POST request to the Overpass API. The downloaded XML data is processed and saved to a file. Ensure WaitForAllDownloads() is called to complete the download. ```lisemscript void main() { DownloadFilePost("http://overpass-api.de/api/interpreter",OSMExtentToXMLPost(Region(0.0,1.0,0.0,1.0),"osm.osm")); WaitForAllDownloads(); } ``` -------------------------------- ### Prepare Sentinel-2 Bands for Classification Source: https://lisemmodel.com/docs/classification This script downloads Sentinel-2 bands, cuts out a specific region, and warps them to a uniform resolution for use in classification. ```plaintext void main() { //get the desired bands in a list array names = GetItemsContaining(GetFilesInDir(),{"B01","B02","B03","B04","B05","B06","B07","B08"}); //set the desired area and create a mask by cutting the second band (which is 10 meter resolution) Region area = Region(301575,334651,5.72216e+06,5.75079e+06); Map mask = RasterCut(LoadMap(names[1]),area); //make a map array, and put each band cut and warped to the right resolution (10 meters) array bands; for(int i = 0; i < names.length(); i++) { bands.Append(RasterWarp(mask,RasterCut(LoadMap(names[i]),area))); } //Store result in multi-band tif file result.tif = bands; } ``` -------------------------------- ### Calculate Slope using LISEM Script Tool Source: https://lisemmodel.com/docs/gettingstarted This command calculates the slope from a Digital Elevation Model (DEM) file and saves the result to a new GeoTIFF file. Ensure the input DEM file is in the current working directory. ```plaintext slope.tif = Slope(dem.tif) ``` -------------------------------- ### Run Support-Vector-Machine Classification Source: https://lisemmodel.com/docs/classification Performs a supervised classification using the Support Vector Machine algorithm on the prepared multi-band raster data and training data. ```plaintext classes.tif = SupervisedClassification(result.tif, training.tif); ``` -------------------------------- ### Estimate Channel Width Source: https://lisemmodel.com/docs/hydrology Estimates channel width using a logarithmic relationship based on accuflux. This formula is derived from empirical observations. ```LISEM Script channelwidth.tif = 9.68*(accuflux.tif/1e6)**0.32 ``` -------------------------------- ### Calculate Drainage Network with Advanced Parameters Source: https://lisemmodel.com/docs/studysite Calculates the drainage network with advanced parameters to control catchment merging, size, and handling of missing values. Useful for refining watershed delineation. ```python ldd.tif = DrainageNetwork(dem.tif,1e6,1e6,1e6,1e6, true) ``` -------------------------------- ### Load Elevation Model Source: https://lisemmodel.com/docs/dynamicmodels Loads a Digital Elevation Model (DEM) from a GeoTIFF file into the script. ```csharp void main() { Map dem = dem.tif; } ``` -------------------------------- ### Generate Drainage Network (LDD) Source: https://lisemmodel.com/docs/elevationdata Creates a Local Drainage Direction (LDD) map from a DEM, indicating the flow direction for each cell. ```python ldd.tif = DrainageNetwork(dem.tif,1e4,1e4,1e4,1e4) ``` -------------------------------- ### Create Channel Mask from Accuflux Threshold Source: https://lisemmodel.com/docs/hydrology Generates a channel mask by applying a threshold to the calculated accuflux. Cells exceeding the threshold are identified as channel cells. ```LISEM Script channelmask.map = MapIf(accuflux.map >> 5000,1.0,0.0); ``` -------------------------------- ### Generate Hillshade from DEM Source: https://lisemmodel.com/docs/elevationdata Creates a hillshade representation of the terrain from a DEM, useful for visualization. ```python hillshade.tif = HillShade(dem.tif) ``` -------------------------------- ### Converting Vector to Raster Source: https://lisemmodel.com/docs/warping Convert a vector dataset to a raster dataset. This can be done by rasterizing an attribute value or by burning a specified value. ```csharp channelwidth.tif = Rasterize(target.map,rivers.shp,"width"); //put attribute value of "width" channelwidth_burn.tif = Rasterize(target.map,rivers.shp,"",true,1.0); //burn value 1.0 ``` -------------------------------- ### Apply Collapsed Operators to Files Source: https://lisemmodel.com/docs/datamanipulation Applies arithmetic operations directly to the data within a raster file, modifying it in place. ```angelscript test.tif += 100 ``` ```angelscript test.tif += dem.map ``` -------------------------------- ### Identify Channel Locations Source: https://lisemmodel.com/docs/elevationdata Selects potential channel locations by applying a threshold to the flow accumulation data. ```python channel.tif = MapIf(accuflux.tif >> 1000.0,1.0,0.0) ``` -------------------------------- ### Apply Window Average Filter Source: https://lisemmodel.com/docs/filters Blurs and smoothens raster data by applying a window average. Adjust the window size (e.g., 100) for more or less smoothing. ```lisem dem_lidar_wa.map = WindowAverage(dem_lidar.map,100); ``` -------------------------------- ### AccuFlux2D Soil Depth Model Source: https://lisemmodel.com/docs/soils An advanced soil depth model using AccuFlux2D for better spatial patterns, especially with custom accuflux maps. Suitable for larger channel networks. ```map soildepthn.map = AccufluxSoil(dem.map,AccuFlux2D(dem.map,dem.map * 0.0 + 1.0,dem.map * 0.0 + 1.0,500,0.2,1.0),dem.map * 0.0 + 0.001,0.0000001,2,500,0.2); ``` -------------------------------- ### Telea Inpainting Source: https://lisemmodel.com/docs/interpolation Uses the Telea inpainting algorithm to fill in data gaps. This method is suitable for larger gaps and considers the surrounding data to fill missing values. ```plaintext inpaint_telea.tif = InpaintTelea(gap.tif,6) ``` -------------------------------- ### Generate Contour Lines from DEM Source: https://lisemmodel.com/docs/elevationdata Creates contour lines from a DEM at a specified interval. ```python contour.shp = RasterContour(dem.tif,50.0) ``` -------------------------------- ### Identify Pits and Catchments Source: https://lisemmodel.com/docs/studysite Identifies pits and defines catchments based on a drainage network. This is crucial for segmenting the study area into distinct hydrological units. ```python pit.tif = Pit(ldd.tif); catchments.tif = Catchments(ldd.tif,pit.tif); ``` -------------------------------- ### Fix Local Depressions in DEM Source: https://lisemmodel.com/docs/elevationdata Corrects local depressions in a DEM by applying pit filling, considering diagonal connections. ```python dem_fix.tif = DrainageNetworkDEM(dem.tif,1e4,1e4,1e4,1e4) ``` -------------------------------- ### Steady State Soil Depth Model Source: https://lisemmodel.com/docs/soils Calculates soil depth using a steady-state model based on flow accumulation. Requires calibration for reliable results. May have issues with large channel networks. ```map soildepth.map = SteadyStateSoil(dem.map,dem.map * 0.0 + 0.1, dem.map * 0.0 + 0.2,100,0.2,1.0); ``` -------------------------------- ### Approximate Distance Transform with Spread Source: https://lisemmodel.com/docs/distances Estimates the lowest friction value from each cell to a source cell. Requires a source mask and friction values. ```plaintext channeldistance.map = Spread(channelmask.map,0.0,1.0) ``` -------------------------------- ### Nearest Neighbor Interpolation Source: https://lisemmodel.com/docs/interpolation Fills in values based on the nearest neighbors. Useful for quick resampling but can result in blocky outputs. ```plaintext nearest.tif = ResampleNearest(dem.tif,4) ``` -------------------------------- ### Reduce Map to Single Value Source: https://lisemmodel.com/docs/datamanipulation Calculates a single summary value from a map, such as the average, and prints it to the output window. ```angelscript Print(MapAverageRed(dem.map)) ``` -------------------------------- ### Estimate Channel Depth Source: https://lisemmodel.com/docs/hydrology Estimates channel depth using a logarithmic relationship based on accuflux. This formula complements the channel width estimation. ```LISEM Script channeldepth.tif = 11.3*(accuflux.tif/1e6)**0.083 ``` -------------------------------- ### Sparse Interpolation Source: https://lisemmodel.com/docs/interpolation Prepares data for other interpolation methods by creating a sparse representation. This can be a precursor for more complex algorithms. ```plaintext sparse.tif = ResampleSparse(dem.tif,4) ``` -------------------------------- ### Infinite Slope Model Calculation Source: https://lisemmodel.com/docs/slopefailure This snippet calculates the Factor of Safety (FoS) using the Infinite Slope model. It requires maps for cohesion, internal friction angle, soil density, and digital elevation model (DEM) data. Ensure all necessary maps are loaded before execution. ```python FoS.map = (coh.map + (thetai.map * 1000.0 + thetas.map * soildensity.map)* tan(ifa.map) * sin(atan(slope(dem.map))) * cos(atan(slope(dem.map))))/((thetai.map * 1000.0 - thetas.map * soildensity.map)* cos(atan(slope(dem.map)))* cos(atan(slope(dem.map)))); ``` -------------------------------- ### Logical Operators for Shapefiles Source: https://lisemmodel.com/docs/datamanipulation Uses logical operators to find intersections or unions between shapefiles, like finding where rivers and roads cross. ```angelscript bridges.shp = rivers.shp | roads.shp ``` -------------------------------- ### Bicubic Interpolation Source: https://lisemmodel.com/docs/interpolation Uses bicubic interpolation, considering a 4x4 neighborhood and second derivatives. This generally provides smoother and more accurate results than bilinear interpolation. ```plaintext cubic.tif = ResampleCubic(dem.tif,4) ``` -------------------------------- ### Create Custom Edge-Preserving Filter Source: https://lisemmodel.com/docs/filters Linearly blends a window-averaged result with the original data based on slope to preserve edges. The blending factor is controlled by the slope. ```lisem dem_lidar_wa2.map = min(1.0,max(0.0,1.0-Slope(dem_lidar.map)))*WindowAverage(dem_lidar.map,50) + min(1.0,max(0.0,Slope(dem_lidar.map)))*dem_lidar.map; ``` -------------------------------- ### Calculate Drainage Network Source: https://lisemmodel.com/docs/studysite Calculates the drainage network from a Digital Elevation Model (DEM). This is a fundamental step for watershed analysis. ```python ldd.tif = DrainageNetwork(dem.tif); ``` -------------------------------- ### Navier-Stokes Inpainting Source: https://lisemmodel.com/docs/interpolation Applies the Navier-Stokes inpainting technique to fill data gaps. Similar to Telea, it uses surrounding data but may produce different results, especially regarding derivatives. ```plaintext inpaint_ns.tif = InpaintNS(gap.tif,6) ``` -------------------------------- ### Extract Catchment Region and Cut DEM Source: https://lisemmodel.com/docs/studysite Extracts a specific catchment's spatial extent and cuts the Digital Elevation Model (DEM) to this region. This allows for focused analysis of individual catchments. ```python Region r = ClassExtent(catchments.tif, 56); dem_cut.tif = RasterCut(dem.tif,r); ``` -------------------------------- ### Apply Deconvolution Filter Source: https://lisemmodel.com/docs/filters Attempts to reverse the effect of a previous smoothing operation (like averaging) by applying a deconvolution filter. Parameters control the filter strength and iterations. ```lisem dem_lidar_deconvolve.map = RasterDeconvolve(dem_lidar.map,10,0.2) ``` -------------------------------- ### Distributing Channel Width with Spread Source: https://lisemmodel.com/docs/distances Distributes river width over neighboring cells using the Spread function when the width exceeds cell size. This involves conversions due to the nature of the spread function. ```plaintext channelwidth_new.map = max(0.0,min(-Spread(MapIf(channelwidth.map >> 0.0,1.0,0.0),-MapIf(channelwidth.map << 10.0, channelwidth.map,10.0+ (channelwidth.map-10)/2),1.0),10)) ``` -------------------------------- ### Apply Frost Noise Filter Source: https://lisemmodel.com/docs/filters Removes sparse errors or noise from a raster dataset using the Frost noise filter. Parameters control the neighborhood size and iteration count. ```lisem dem_lidar_frost.map = NoiseFilterFrost(dem_lidar_noise.map,3,1) ``` -------------------------------- ### Machine Learning Super-Resolution Interpolation Source: https://lisemmodel.com/docs/interpolation Applies a deep neural network model for super-resolution, significantly improving interpolation quality and preserving visual detail. The model can be applied repeatedly, but may introduce artifacts. ```plaintext sr.tif = ApplyMLModel({dem.tif},"DahalModel.onnx",32,32,{0,3,1,2},true) ``` ```plaintext sr2.tif = ApplyMLModel({sr.tif},"DahalModel.onnx",32,32,{0,3,1,2},true) ``` -------------------------------- ### Mean-Shift Segmentation Source: https://lisemmodel.com/docs/segmentation Applies mean-shift segmentation to a raster image. Use this to group pixels with similar characteristics into distinct segments. Parameters control the search window size and the minimum segment size. ```python segmentation.tif = SegmentizeMS(sentinel.tif,100,500,20,200) ``` -------------------------------- ### Calculate Accuflux Source: https://lisemmodel.com/docs/hydrology Calculates the accuflux based on the drainage network (LDD). This is a precursor to identifying channel cells. ```LISEM Script accuflux.map = Accuflux(ldd.map,1.0); ``` -------------------------------- ### Saxton Pedotransfer Functions Source: https://lisemmodel.com/docs/soils Provides Saxton et al. (2006) pedotransfer functions to estimate soil properties like saturated hydraulic conductivity (ksat), soil water retention (suction, field capacity, porosity), and parameters A and B. ```map ksat.tif = SaxtonKSat(sand.map,clay.map,organic.map,gravel.map); ``` ```map sucton.tif = SaxtonSuction(sand.map,clay.map,organic.map,saturation.map,gravel.map); ``` ```map thetar.tif = SaxtonFieldCapcity(sand.map,clay.map,organic.map,gravel.map); ``` ```map thetas.tif = SaxtonPorosity(sand.map,clay.map,organic.map,gravel.map); ``` ```map A.tif = SaxtonA(sand.map,clay.map,organic.map,gravel.map); ``` ```map B.tif = SaxtonB(sand.map,clay.map,organic.map,gravel.map); ``` -------------------------------- ### Calculate Confusion Matrix Source: https://lisemmodel.com/docs/classification Generates a confusion matrix to compare two classified maps, useful for evaluating classification accuracy or comparing different methods. ```plaintext confusionmatrix.tbl = MapConfusionMatrix(classes.tif,classes_unsuper.tif); ``` -------------------------------- ### Bilinear Interpolation Source: https://lisemmodel.com/docs/interpolation Performs bilinear interpolation, which considers a 2x2 neighborhood. This method maintains data derivatives better than nearest neighbor. ```plaintext linear.tif = ResampleLinear(dem.tif,4) ``` -------------------------------- ### Calculate Error using MapContinuousCohensKappa Source: https://lisemmodel.com/docs/calibration Calculates the error value using the MapContinuousCohensKappa function, which is a continuous adaptation of the Cohens Kappa performance metric. ```lisemscript double errorval = MapContinuousCohensKappa(inventory,impact,1.0); ``` -------------------------------- ### Calculate Flow Accumulation Source: https://lisemmodel.com/docs/elevationdata Computes the accumulated flow into each cell based on a drainage network map. ```python accuflux.tif = Accuflux(ldd.tif,1.0) ``` -------------------------------- ### Add Layer to Map Viewer Source: https://lisemmodel.com/docs/datamanipulation Adds a specified raster layer to the LISEM map viewer. ```angelscript AddViewLayer(dem.asc) ``` -------------------------------- ### Calculate Cohens Kappa Error for Landslide Runout Source: https://lisemmodel.com/docs/lisemcalibration Use this function to calculate the Cohens Kappa metric for comparing binary landslide impact predictions against observed data. This method corrects for biases present in simpler accuracy calculations. ```plaintext double errorval = MapContinuousCohensKappa(inventory.map,impact.map,1.0); Print("Error is: " + ToString(errorval)); ``` -------------------------------- ### Warping Raster to a Target Raster Source: https://lisemmodel.com/docs/warping Warp a raster dataset directly to match the extent, CRS, and cell sizes of an existing target raster file. ```csharp warped.tif = RasterWarp(target.tif,GeoProjectionFromWGS84UTM(30,true)); ``` -------------------------------- ### Perform Unsupervised Classification Source: https://lisemmodel.com/docs/classification Conducts an unsupervised classification by specifying the desired number of classes. This method can help clip value ranges and remove outliers. ```plaintext classes_unsuper.tif = UnSupervisedClassification(result.tif, 5); ``` -------------------------------- ### Access Specific Raster Band Source: https://lisemmodel.com/docs/datamanipulation Selects and uses a specific band from a multi-band raster file for calculations. ```angelscript layer.map = layers.tif[0] + layer.tif[1] ``` -------------------------------- ### Estimate Soil Depth Map Source: https://lisemmodel.com/docs/hydrology Uses the AccufluxSoil function to estimate the soil depth map based on a digital elevation model (DEM). This function requires several parameters related to flow accumulation and soil properties. ```python soildepth.map = AccufluxSoil(dem.map,AccuFlux2D(dem.map,dem.map * 0.0 + 1.0,dem.map * 0.0 + 1.0,500,0.2,1.0),dem.map * 0.0 + 0.001,0.0000001,2,500,0.2); ``` -------------------------------- ### Estimating Travel Effort with Varying Friction Source: https://lisemmodel.com/docs/distances Estimates travel effort or times by considering spatially varying friction, such as roads and slopes. The friction is lower on roads and higher on non-roads and steeper slopes. ```plaintext traveleffort.map = Spread(coast.map,0.0,MapIf(roadwidth.map >> 1,1 + slope.map,2 + 5 * slope.map)) ``` -------------------------------- ### Compound Map Calculations Source: https://lisemmodel.com/docs/datamanipulation Performs complex calculations involving multiple maps and mathematical functions. Ensure all rasters have the same dimensions. ```angelscript calc.tif = dem.tif + slope.map^2.0 + sin(atan(sqrt(dem.map))) ``` -------------------------------- ### Detect Linear Features Source: https://lisemmodel.com/docs/datamanipulation Identifies linear features in terrain data, such as rivers or roads, and saves them as a shapefile. ```angelscript lines.shp = LineDetect(Slope(dem.map)) ``` -------------------------------- ### Euclidean Distance Transform Source: https://lisemmodel.com/docs/distances Calculates the actual Euclidean distance to the closest source cell. Requires an inverted input mask. ```plaintext channeldistance.map = DistanceTransform(~channelmask.map) ``` -------------------------------- ### Kriging Interpolation Source: https://lisemmodel.com/docs/interpolation Provides a statistically sound estimate of the most likely value using Kriging. Note that this method tends to under-estimate variability in the dataset. ```plaintext kriging.tif = Kriging(sparse.tif,10) ```