Introduction
In 2024, I published an article illustrating how HexSim could be used to conduct connectivity analyses. That paper, A rapid assessment methodology for quantifying and visualizing functional landscape connectivity, is available at https://doi.org/10.3389/fcosc.2024.1412888.
This publication illustrated how data from a HexSim movement-only simulation model could be used to bring biological realism and defensibility to connectivity assessments. Most of the computational work this entails is performed by my C-language program titled LINK. Program LINK is available here.
Below, I describe LINK in detail, and walk users through an illustrative connectivity assessment, from start to finish. I have updated LINK since the above article was published, and will continue to do so. Readers will want to use this new version of LINK, rather than the one available via the publication.
A. Background
This document walks readers through an example connectivity assessment. Many of the tasks below involve two additional software packages. XnView (www.xnview.com) is a platform for viewing and manipulating raster imagery. I use the “Classic” version of XnView to display maps, and to convert images from a Sun Raster format (https://en.wikipedia.org/wiki/Sun_Raster) into PNG files. Cygwin (www.cygwin.com) is a Unix operating system that runs on Windows. I use Cygwin to compile and run the software utilities I’ve written. Both XnView and Cygwin are free. Note that there are alternatives to XnView and Cygwin; these are just the applications I'm the most familiar with.
When installing Cygwin, users will want to be sure to include the C-language packages. Once that has been done, my utilities can be compiled by typing “cc <utility>.c”, where <utility> is replaced by the name of the program. I will often leave off the “.c” and “.exe” extensions when referring to my software utilities.
Below, I include reproductions of Cygwin input and output. This content will be displayed as:
CMD-# utility parameters
CMD-# is simply a running counter I'll use to distinguish between commands. Utility, in this context, will be replaced with the name of a compiled computer program, and parameters are values passed to that program. All of my utilities should generate a usage statement when run in Cygwin without any command-line arguments. In the content below, I will assume readers have already compiled the utilities.
Many of my programs require the specification of input or output “hexmaps”, which are just maps made up from collections of hexagonal cells. Users will frequently need to supply the hexmap geometry by entering the number of rows, plus the minimum and maximum number of columns per row. Hexmaps can be “wide” (all rows contain the same number of hexagons), or “narrow” (even rows are one hexagon shorter).
B. Obtaining the Example Data and Utilities
Prior to using LINK, readers must first obtain some input data and other software utilities. These can all be found within the zip file from which this document was extracted. Readers will need each of the following files:
Habitat.asc A fabricated map of integer resource patches.
asc2csv.c Builds a hexmap from an ASCII Grid file.
asc2sun.c Builds a Sun Raster from an ASCII Grid file.
assign_patch_id.c Converts a hexmap into a patch map.
bin_hexmap.c Adds contrast to the connectivity hexmaps.
csv2png.py Builds a PNG image from a CSV hexmap.
csv2sun.c Builds a Sun Raster from a CSV hexmap.
LINK.c Performs connectivity assessments.
randomize_patches.c Randomizes the IDs of patch map patches.
run_movement.c Simulates movement within a hexmap.
scan_ascii_grid.c Quantifies the content of an ASCII Grid file.
The first item above is a fabricated habitat map that we’ll use as input to the program named run_movement. We’ll also use the habitat map to construct a patch map, since patch maps are required by the LINK utility. Before we can proceed with run_movement or patch map construction, we must first convert the Habitat.asc into a hexmap.
The remaining items in the above list are software utilities. The download includes C-language utilities, plus one python program (an alternative to csv2sun.c). I find csv2sun.c easier to use than csv2png.py. But the latter is necessary for extremely large hexmaps, as there is apparently an upper limit on Sun Raster file image size.
C. Building Hexmaps and Simulating Movement
This section takes readers through the process of assembling the input data required by the LINK utility. The steps in this section require use of some of the files, described in Part B, that I have made available for download.
Step C1. Examining the Input Habitat Map
Here, we begin by interrogating and visualizing the habitat map titled "Habitat.asc". First, we’ll use the scan_ascii_grid utility to gather some basic information about Habitat.asc. This utility’s output will differ depending on whether the input map contains integer or floating point data. A reproduction of the Cygwin command and output is shown below.
CMD-01 scan_ascii_grid Habitat.asc
This Image Contains Integer Data
Image Header Information
Nbr Cols = 2500
Nbr Rows = 2500
Non-Data = -9999
Data Max = 9
Image Histogram
No-Data Pixels: 0
Category 0: 2209594
Category 1: 1025692
Category 2: 713918
Category 3: 529986
Category 4: 434036
Category 5: 322740
Category 6: 307128
Category 7: 261446
Category 8: 222306
Category 9: 223154
Second, we’ll create an image of the ASCII Grid file. To do this, issue the Cygwin statement:
CMD-02 asc2sun Habitat.asc Habitat_Raster.sun 1
In the above command, Habitat.asc and Habitat_Raster.sun are the input and output filenames. The 1 at the end of the command line tells the utility to use a blue-yellow-red colormap. Low values will be displayed in blue, intermediate values in yellow, and high values in red. The other valid colormap option is 0, which produces an image that trends from red to yellow to blue.
Now, we can use XnView to visualize the Sun Raster image, and convert it into a PNG file (Fig. S1, left).