Home
Help
Resources
Extensions
FAQ
NetLogo Publications
Donate

Models:
Library
Community
Modeling Commons

Beginners Interactive NetLogo Dictionary (BIND)
NetLogo Dictionary

User Manuals:
Web
Printable
Chinese
Czech
Farsi / Persian
Japanese
Spanish

# Contour30

by Garrett Love (Submitted: 08/23/2019)

 Download Contour30 If clicking does not initiate a download, try right clicking or control clicking and choosing "Save" or "Download".(The run link is disabled for this model because it requires NetLogo 3D 6.0.4, which NetLogo Web does not support.)

## WHAT IS IT?

This model constructs an isopleth (or "contour") map of a value that varies in 2-dimensional space, interpolating from a set of up to 30 values and associated coordinates.

## HOW IT WORKS

The model first divides the 2-dimensional space into triangles with vertices at each coordinate pair in the "point set". These triangles are created such that the minimum angle of each triangle is maximized, which avoids sliver triangles (thin triangles with two highly acute angles). This construction, known as a Delaunay Triangulation, also has the defining characteristic that the circumcircle of every triangle contains none of the (other) points in the set.

The model uses the Bowyer-Watson algorithm for computing the Delaunay triangulation, establishing four points in a "super square" around the original point set, and then incrementally considering each point within the square, removing and adding connections to maintain a viable triangulation. The added vertices are then removed from consideration leaving the desired triangulation.

The sides of each triangular element are then divided into increments using linear interpolation that compares the values at each vertex to the distances between. Increments of similar value along each side of a triangle are then connected with segments to create lines of equal value, i.e. isopleths or contour lines.

## HOW TO USE IT

X1,Y1,X2,Y2,...: The user can enter a desired set of coordinates into the provided input boxes being sure that the values stay within the range listed as 'minimum x','maximum x','minimum y' and 'maximum y' in the monitors below the viewscreen. Each ordered pair should also be unique. Screen size can be expanded using SETTINGS which will be reflected in the min-max monitors.

POINT1, POINT2, ...: Each spatial point can be toggled ON or OFF using the switch to have the point included in (ON) or excluded from (OFF) the point set, but note that each active point should have a unique location to avoid an error message.

VAL1, VAL2,...: These input boxes are provided to associate a scalar value with each spatial point. These are values that will be interpolated to create the contour map.

DISPLAY: When pressed, just displays all the active points with an identifying label

TRIANGULATE: When pressed, displays all the active points with an identifying label and then calculates and displayes the Delaunay triangulation of the active spatial points. Intermediate triangulations following the Bowyer-Watson algorithm are temporarily displayed but may not be visible unless the model is adjusted to a slower speed.

CONTOUR: When pressed, calculates a series of intervals based on the value of the NUM-INTERVALS slider and displays isopleth values for each interval boundary in the 'contours' monitor (one more than the number of intervals). It then constructs and displays isopleths in the triangulation with labels. Only functions if a triangulation has been already computed, but will recalculate new contours if adjustments have been made to VAL# values.

NUM-INTERVALS: Establishes the number of intervals to be visualized with contour lines, spaced at equal intervals between the minimum and maximum active values in the point set OR the range values specified by ALT-MIN-VAL and ALT-MAX-VAL. Note that the interval is rounded to 3 significant digits.

ALT-MIN-VAL: Establishes an alternative value for the lowest value contour line, only if it is less than the smallest of the current active data points (as displayed in the 'Min value' monitor).

ALT-MAX-VAL: Establishes an alternative value for the highest value contour line, only if it is greater than the largest of the current active data points (as displayed in the 'Max value' monitor).

TOGGLE TRIANGLES: When pressed, renders the triangulation lines invisible (or visible), allowing for better view of the contour lines.

TOGGLE POINTS: When pressed, renders the data point markers and labels invisible (or visible), allowing for better view of triangulation and/or contour lines.

FIT-TO-FRAME?: If ON when DISPLAY or TRIANGULATE is pressed, the data points will be scaled in the x and y dimensions and recentered in the 3D View

SHOW3D?: If OFF when DISPLAY or TRIANGULATE is pressed, the data points will be plotted with a z-coordinate value of 0. If ON, each point will be plotted with a z-coordinate scaled to the associated value.

## THINGS TO TRY

Adjust the speed slider towards "slower" to watch a visualization of the Bowyer-Watson calculation.

Gather data (eg. precipitation, temperature, elevation) from an online resource or classroom experiment and create a contour plot. Note that you may need to scale units, particularly the spatial coordinates.

Turn many of the points in a data set "Off" and generate a contour with limited data.
Turn some of the points back "On" and regenerate the contour. Consider how the addition of data changes the contour and the estimated values in other spatial locations.

## NETLOGO FEATURES

Each point in the point-set is associated with a mobile agent (a turtle of breed "point") and triangle sides and isolines are established as undirected links (of breed "edge" and "iso"). Additional agents of breed "triangle" are created to establish connectivity and to facilitate the logic for determining whether a point is within the circumcircle of a given triangle (by comparing the distance of that point from the circumcenter of the triangle to the radius of the circumcircle).

The model makes extensive use of anonymous procedures ("->" syntax) to deal with the sets of different agent types.

## AUTHORSHIP
Created Jan 2018
Garrett Love, Ph.D.
Engineering Instructor
NC School of Science and Math

This work supported by the National Science Foundation
STEM + C Award 1543228
Comp Hydro: Integrating data, computation, and visualization for model-based water literacy