Geospatial triangular interpolation with Python, Scipy, Geopandas and Rasterio - Tutorial

Under the concept of “applied geospatial Python” we have developed some procedures / tutorials of some common spatial analysis tasks done on desktop GIS software. The aim isn’t to reinvent the wheel but to explore the current Python tools and libraries that can create, analyze and represent both vector and raster spatial data.

Triangular interpolation is one of several types of interpolation techniques available in both Python and GIS software, however the advantage of working with Python is that the interpolation is a function where you can get the interpolated value on a specific point while in GIS software you are required to create a raster and sample values from the raster (.. as far as we know).

We have created a tutorial with a complete procedure in Python to import points with elevation as a attribute, creates a triangular interpolation function and has two spatial outputs: an interpolated geospatial raster in TIFF format and a shapefile with elevation attribute for another set of points. The tutorial uses several Python libraries as Matplotlib, Rasterio, Geopandas, Scipy.

Read More
2 Comments

 

Suscribe to our online newsletter

Subscribe for free newsletter, receive news, interesting facts and dates of our courses in water resources.

 

Hatarichem v2, the online tool to create Piper, Schoeller and Stiff Diagrams

We present our own webapp for the representation of the Piper Diagram, Stiff Diagram and Scholler Diagram. The webapp was developed in Python Django and it is entirely free for everyone. The main objective behind this webapp was to develop a user friendly and minimum requirement tool to create these water quality / hidrogeochemical diagrams. The video tutorial shows the complete procedure to update the working file and then generate the diagrams.

Read More

 

Suscribe to our online newsletter

Subscribe for free newsletter, receive news, interesting facts and dates of our courses in water resources.

 

Basic example of hydrological modeling at basin scale with HEC HMS 4.5

HEC HMS is a software developed by the US Corps of Engineers that implements a series of hydrological methods to represent different physical process of the water cycle. The tools and options of HEC HMS make it a very versatile and powerful software for the hydrological simulation of different escenarios as extreme events on arid regions, or water balances in wet climates.

This tutorial shows the complete procedure to set up and simulate the hydraulic response of a 8 hour storms over a 20 hour period, model results are intended to show maximum flows and flow development with time. The area of study is a andean basin that was divided on two sub-basins (high and low part), each one has their own storm precipitation data. The model consider the use of hydrological components as subbasin, reaches and sinks.

Read More

 

Suscribe to our online newsletter

Subscribe for free newsletter, receive news, interesting facts and dates of our courses in water resources.

 

How to make a Piper Diagram in Python - Tutorial

A Piper Diagram is an effective graphic procedure to segregate relevant analytical data to understand the sources of the dissolved constituents in water. This procedure was born under the statement that most natural waters contain cations and anions in chemical equilibrium. It is assumed that the most abundant cations are calcium (Ca), magnesium (Mg) and sodium (Na). The most common anions are bicarbonate (HCO3), sulphate (SO4) and chloride (Cl).

The Piper diagram can be made by free and commercial desktop software, however in this tutorial we have generated the Python scripts and working procedure to create a Piper Diagram from values stored in a working spreadsheet.

Read More

 

Suscribe to our online newsletter

Subscribe for free newsletter, receive news, interesting facts and dates of our courses in water resources.

 

Dynamic Flood Simulation of Combined Peak Flows with HEC-RAS - Tutorial

Flood events come from periods of high precipitiation and favourable soil moisture conditions. Based on the basin topography, land cover and precipitation distribution, flood events can be conceptualized as the cummulative sum of a series of peak flows from different affluent rivers.

Flood management involve the prediction of river water elevation and velocitiy from extreme precipitation events. This tutorial shows the procedure to build a unsteady (dynamic) flow simulation of two peak flows with different hydrograms. The channel network configuration for the area of study consists of one main river and a affluent river. Peak flow in the main river is 10 hours ahead of the peak flow in the affluent river.

Read More

 

Suscribe to our online newsletter

Subscribe for free newsletter, receive news, interesting facts and dates of our courses in water resources.

 

How to create a boxplot to represent basin scale water constituents using Python - Tutorial

Python is an interpreted high-level programming language which allows performing several statistical procedures. This programming language is an excellent option to create box plots because of its simplicity and exceptional results. This tutorial explains how to download and use Python´s Jupyter Notebook to analyze water quality data in the form of boxplots.

Box plots show the distribution of a sample using the lower quartile (Q1), the median (m or Q2) and the upper quartile (Q3)--and the interquartile range (IQR = Q3-Q1), which covers the central 50% of the data. Quartiles are values that divide the data in quarters; the term refers to the value that falls in the line that divides each quarter. Therefore, Q1 is the highest value of the first 25% of the data, Q2 is the one of the 50% of the data and Q3, the one for the 75% of the data. Characterizing the data with quartiles is advantageous because they are insensitive to outliers and preserve information about the center and spread (Krzywinski & Altman 2014).

Read More

 

Suscribe to our online newsletter

Subscribe for free newsletter, receive news, interesting facts and dates of our courses in water resources.

 

What is a Piper diagram for water chemistry analysis and how to create one?

In 1994, Arthur M. Piper, proposed an effective graphic procedure to segregate relevant analytical data to understand the sources of the dissolved constituents in water. This procedure was born under the statement that most natural waters contain cations and anions in chemical equilibrium. It is assumed that the most abundant cations are two “alkaline earths” calcium (Ca) and magnesium (Mg) and one “Alkali” sodium (Na). The most common anions are one “weak acid” bicarbonate (HCO3) and two “strong acids” sulphate (SO4) and chloride (Cl). Less common anion and cation-constituents are summed with the major three anions and cations as shown in the following table:

Read More

 

Suscribe to our online newsletter

Subscribe for free newsletter, receive news, interesting facts and dates of our courses in water resources.

 

Dynamic Simulation of Hillslope Landslide with openFoam - Tutorial

This tutorial shows the whole procedure to simulate a landslide of a hillslope from a initial condition of failure. The tutorial was done with the interFoam solver from openFoam on a non- Newtonian flow. The fluid has a variable kinematic viscosity (nu) based on the Bird-Carreau model. Failure scenario last only 6 seconds and results were recorded every 0.1 seconds. Final geometry and the landslide development were analyzed with paraView with predefined views (paraView states).

Read More

 

Suscribe to our online newsletter

Subscribe for free newsletter, receive news, interesting facts and dates of our courses in water resources.

 

Modeling and Analysis between 5 Newtonian Fluids in OpenFOAM - Tutorial

Computational fluid dynamics modeling with OpenFOAM could be challenging for water resources engineers since OpenFOAM models all types of fluids like water, air, heat and electromagnetism. On a normal hydrological software, it is implicit that the physical properties or the empiric formulation matches water on the liquid phase at temperatures around 20°C; however in a CDF program as OpenFOAM we have to define that the fluid we are working with is water and this increases the level of complexity on the model conceptualization and analysis.

But there is a interesting face of this complex fluid formulation in OpenFOAM: we can model any fluid, fluid type and turbulence condition; that means that we can model fluids like oil, alcohol, beer, or glycerine just with their property definition. In this tutorial we model and compare the behavior of 5 Newtonian fluids: beer, benzene, glycerine, olive oil and water. All fluids have been simulated on the same geometry and timeframe and all simulation output have been integrated in one paraView session for the comparative analysis of the fluid performance. Fluids were modeled with the interFOAM solver on turbulent conditions with the k-epsilon schema.

Read More

 

Suscribe to our online newsletter

Subscribe for free newsletter, receive news, interesting facts and dates of our courses in water resources.

 

Floating Object Stability Modeling with OpenFOAM - Tutorial

This tutorial is about a floating object stability simulation from a water surface oscillation (wave). The model was done with the interFoam solver that is a solver for two incompressible fluids, on isotermic conditions using a volume of control (VOF) phase-fraction interface approach. Turbulence was conceptualized on the model with the kEpsilon turbulence model. Simulation was done for 4 seconds with outputs every 0.05 seconds and runs in almost 5 minutes on OpenFOAM for Windows, better computation times are expected when run on Linux with paralleling computing.

Read More

 

Suscribe to our online newsletter

Subscribe for free newsletter, receive news, interesting facts and dates of our courses in water resources.

 

Modeling Effluent Disposal Mixing Zone into the Ocean with OpenFOAM - Tutorial

A right assessment of the effluent mixing zone would require a baseline of sea currents, discharge flows, seawater and effluent density, bathymetry, waves, infraestructure geometry and a tool that can analyse the interaction of the mentioned factors. OpenFOAM is a numerical model for Computational Fluid Dynamics (CFD) modeling capable of modeling fluids with complex geometries, conditions and requirements; with OpenFOAM one can model compressible/uncompressible, single phase / multiphase, flows that mix, non-newtonian flows, etc. OpenFOAM comes with build-in tools for model construction and visualization, and there is Salome Platform for advanced mesh generation.

This tutorial show the entire procedure for the simulation of a effluent of 40 l/s into the ocean that has a current of 0.05 m/s. The model is on transient conditions, model simulation were done under uniform discharge rates, the development of the mixing zone was analyzed with paraView tools and a water chemistry component was introduced into the simulation with some Python scripts. 

Read More

 

Suscribe to our online newsletter

Subscribe for free newsletter, receive news, interesting facts and dates of our courses in water resources.

 

OpenFOAM Model Local Mesh Refinement with Salome and Python3 - Tutorial

Discretization is the “art” of transforming a continuous media as nature into discrete parts; for numerical models the spatial and temporal discretization have become a key issue in assuring model efficiency, output precision and the overall quality of the modeling work. Flow models are constructed to represent an specific requirement on the surface water/ groundwater flow regime (local scale), however, the model has to represent first the overall flow regimen (global scale). On the general model areas, an efficient spatial discretization criteria rules to keep the mesh elements as big as possible, meanwhile, in the areas of interest the model should be discretized into the smallest parts.

Read More

 

Suscribe to our online newsletter

Subscribe for free newsletter, receive news, interesting facts and dates of our courses in water resources.

 

Object / fluid interaction modelling with OpenFOAM - Submarine Case - Tutorial

This tutorial will apply OpenFOAM to simulate the flow effect on submerged object using the simpleFoam solver and the k-epsilon turbulence schema. The tutorial develops the case of a submarine model against a flow current; the velocity and pressure applied on the submarine will be analyzed on the model results and flow paths will be plotted to see the main patterns around the submarine. Model output visualization is performed on Paraview that allows the representation of velocity and pressure vectors over the submarine.

Read More

 

Suscribe to our online newsletter

Subscribe for free newsletter, receive news, interesting facts and dates of our courses in water resources.

 

Energy Dissipator Modelling in Open Channels with OpenFOAM - Tutorial

This tutorial will demonstrate the modelling configuration to simulate a power dissipator in an open channel. The dissipator design is proposed on the Stormwater Drainage Manual from the Drainage Services Department of Hong Kong and  OpenFOAM will be used for the simulation with the interFoam solver since two immiscible and isothermal fluids are involved (water and air). The main variable of interest on the dissipator simulation is flow velocity to assess the efficiency of the dissipator.

Read More

 

Suscribe to our online newsletter

Subscribe for free newsletter, receive news, interesting facts and dates of our courses in water resources.

 

Download Climate Change Data (2006-2096) on Daily Scale from NASA NCCS Server with Python - Tutorial

There are many Global Circulation Models (GCMs) with historic and future data of Precipitation, Maximum Temperature and Minimum Temperature for different emission scenarios. Data is available on daily timescale from particular servers, in this tutorial we will show the main characteristics of the NASA NCCS THREDDS Data Server that provide the NASA Earth Exchange Global Daily Downscaled Projections (NEX-GDDP) dataset that has two of the four greenhouse gas emissions scenarios. Data from this dataset is available from 1950 to 2100 separated on historic and future with a spatial resolution of 0.25 degrees (~25km x 25 km). The tutorial show the main parts of the web server and scripts in Python to locate the closest model cell and to recursively download group of records.

Read More

 

Suscribe to our online newsletter

Subscribe for free newsletter, receive news, interesting facts and dates of our courses in water resources.

 

How to download Climate Change data from the World Bank Data API with Python

World Bank has a Climate Change Knowledge Portal with information, data and reports about climate change around the world. The portal has an Climate Data API as REST framework that can provide Precipitation and Temperature data on historic and modeled dataset from 15 global circulation models (CGMs) and 2 emissions scenarios at country and basin spatial scale. There is a Python package called wbpy that makes really easy the access to the Climate Data API by few lines of code. There are options to download data on monthly, annual and decade timescale as Python dictionary data type. This tutorial show the main parts of the API, the involved codes and a example of usage for historic and future data.

Read More

 

Suscribe to our online newsletter

Subscribe for free newsletter, receive news, interesting facts and dates of our courses in water resources.

 

Fill Missing Precipitation Data with Artificial Intelligence (Python Keras) - Tutorial

Evaluation of hydrological processes as evapotranspiration, runoff, routing and infiltration require data as precipitation, flow, temperature and radiation on a daily basis. Required data for the hydrological modeling need to be accurate and must be completed over the period of study. Many times historical data from hydrological stations are incomplete and present many gaps that can be filled by the use of Artificial Intelligence tools as the Keras library in Python.

This tutorial show the procedure to run a complete script for the filling of missing precipitation in one station by the use of data from 2 nearby stations. The Python script is done on a Jupyter Notebook.

Read More

 

Suscribe to our online newsletter

Subscribe for free newsletter, receive news, interesting facts and dates of our courses in water resources.

 

Sedimentation Tank Design with OpenFOAM - Tutorial

Drinking and residual water treatment, water intake into hydroelectric power stations or water treatment for industrial processes require the removal of suspended particles by sedimentation tanks. These hydraulic structures have a slow speed water inlet and a geometry that allows the decantation or precipitation of sediments along the settler path.

OpenFOAM is a open source software for Computational Fluid Dynamics (CFD) modeling with a series of solvers for different flow conditions. In this case we have used the driftFluxFoam solver to represent sediment precipitation in a sedimentator in a transient simulation of 6400 seconds. The tutorial contains 2 videos with the model description and its simulation.

Read More

 

Suscribe to our online newsletter

Subscribe for free newsletter, receive news, interesting facts and dates of our courses in water resources.

 

Crop Yield Assessment from Photos with Python and Scikit-Learn

Evaluation of crop yield can be tedious because sampling methods requires the actual counting of fruits for a whole tree or canopy area. If we want to optimize this time demanding task we can use new and open source machine learning algorithms available. We have selected Scikit-Learn for this tutorial, a machine learning library in Python for it ease to use, the available documentation and the sort of available tools. 

The tutorial covers the whole procedure of image representation, point of interest selection, template matching, cluster analysis and fruit counting. Python scripting was done in Jupyter Notebook, it is interactive and allows the user to add more points of interest or remove inaccurate points.

Read More

 

Suscribe to our online newsletter

Subscribe for free newsletter, receive news, interesting facts and dates of our courses in water resources.

 

How to convert GTIFF to STL for Topography Representation in OpenFOAM Models

For OpenFOAM modelers the representation of topography can be painful due to the unstabilities and complexities of the Bezier Surfaces in Salome Platform. It is more stable to create the mesh by importing a full textured surface on a format file compatible with Salome. This tutorial show the process to create a STL file from a GeoTiff(.tif) file by scripts in Python. We have used the OSGeo4W Shell that comes with the normal QGIS instalation because it comes with the gdal library already installed.

Read More

 

Suscribe to our online newsletter

Subscribe for free newsletter, receive news, interesting facts and dates of our courses in water resources.