Home Download Help Forum Resources Extensions FAQ NetLogo Publications Contact Us Donate Models: Library Community Modeling Commons Beginners Interactive NetLogo Dictionary (BIND) NetLogo Dictionary User Manuals: Web Printable Chinese Czech Farsi / Persian Japanese Spanish

NetLogo User Community Models(back to the NetLogo User Community Models) Contour30by Garrett Love (Submitted: 08/23/2019)
## WHAT IS IT?
This model constructs an isopleth (or "contour") map of a value that varies in 2dimensional space, interpolating from a set of up to 30 values and associated coordinates.
## HOW IT WORKS
The model first divides the 2dimensional 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 BowyerWatson 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 minmax 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 BowyerWatson 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 NUMINTERVALS 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.
NUMINTERVALS: 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 ALTMINVAL and ALTMAXVAL. Note that the interval is rounded to 3 significant digits.
ALTMINVAL: 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).
ALTMAXVAL: 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.
FITTOFRAME?: 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 zcoordinate value of 0. If ON, each point will be plotted with a zcoordinate scaled to the associated value.
## THINGS TO TRY
Adjust the speed slider towards "slower" to watch a visualization of the BowyerWatson 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.
## NETLOGO FEATURES
Each point in the pointset 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
This work supported by the National Science Foundation
This work is licensed under the Creative Commons AttributionNonCommercialShareAlike 4.0 International License. To view a copy of this license, visit http://creativecommons.org/licenses/byncsa/4.0/.
## CREDITS AND REFERENCES
En.wikipedia.org. (2017). Bowyer–Watson algorithm. [online] Available at: https://en.wikipedia.org/wiki/BowyerWatson_algorithm [Accessed 20 Dec. 2017].
Bowyer, Adrian (1981). "Computing Dirichlet tessellations". Comput. J. 24 (2): 162–166.
Watson, David F. (1981). "Computing the ndimensional Delaunay tessellation with application to Voronoi polytopes". Comput. J. 24 (2): 167–172. 
(back to the NetLogo User Community Models)