This Python script calculates divergence, curl magnitude and speed variations along flow lines for a 2D vector field.
Input data must be provided as two Arc/Info ASCII grids, storing the x- and y-components of the vector field.
The results consist in a series of three Arc/Info ASCII grids, with the resulting curl, divergence and speed variations,
as well as a VTK file, storing the input data and the results. The names of input and output files are in a text
See Glacial flow analysis with open source tools: the case of the Reeves Glacier grounding zone, East Antarctica for script rationale.
Code and useExample command line to run the script:
See Input and output section below for parameter file content specifications.
Divergence and curl are two vector operators widely used in physics and engineering, for example, for the study of water flows. The nabla differential operator allows to calculate these two operators from a vector field:
The divergence is a scalar value derived from the scalar product of nabla and the vector field in the neighborhood of a point (x, y, z):
while the curl is the vector product of nabla and the vector field:
With GIS data, we usually consider 2D dimensionality. Therefore, we only consider partial derivatives with respect to x and y axes. For the curl, we will have a vertical vector (parallel to k), whose magnitude is equal to the last component of the curl formula.
To determine the velocity variations per unit length along flow directions, we modify the equation
for a DEM directional slope (Neteler & Mitasova, 2008, eq. A.27):
velocity change per unit length = (dz/dx) * sin(alpha) + (dz/dy) * cos(alpha)
where alpha is the local orientation of the flow line.
All results will consist of scalar fields, because only curl magnitude is of interest.
Input and output
Input and output file names are in a text parameter file:
input vy grid: ASCII grid with y components of vector field
output divergence grid: ASCII grid with divergence values
output curl grid: ASCII grid with curl magnitudes
output speed variation grid: ASCII grid with speed variation along flow lines
output VTK file: VTK file storing input and output data (null value: -99.0)