/marineDistances

Minimum marine distances between sites in any region of the world.

Primary LanguageR

Contour : Pairwise Marine Distances

Minimum marine distances between sites in any region of the world.

How it works?

A high-resolution polygon is converted to an infinite resistance surface.
Minimum distances between sites are computed with a shortest path algorithm considering the infinite resistance of land and null resistance throughout the sea.
The outcomes are a matrix of pairwise distances, a figure to visualize if sites are well represented in the study area and a figure depicting an example of a shortest marine distance.
The main file with the sites should be structured as “Name Lon Lat” or “Name Lat Lon”. Coordinates must be in decimal degrees.

Getting Started

Instructions to get the project up and running on your local machine.

Prerequisites

Install the last verion of R available at The Comprehensive R Archive Network. Download a high resolution polygon depicting the surface of the world (e.g., Global Self-consistent Hierarchical High-resolution Shorelines; https://www.ngdc.noaa.gov/mgg/shorelines/gshhs.html)

Running the code

Open R and set the working directory (path to)
Load the main function "contour" into memory (bellow)
Run the main function "contour"
The main file with the locations should be text delimited
Provide the path of the polygon depicting the surface of the world
Define the delimiter and decimal character of the text file
Define the main file structure: 1 to "Name Lon Lat" or 2 to "Name Lat Lon"
Define if the text file has a header with the column names (TRUE or FALSE)
Define the resolution of the study area and the buffer to use around the sites. The buffer can be a simple value or a vector such as c(xmin,xmax,ymin,ymax). Choose to export the results as a text delimited file (TRUE or FALSE)

contour(  global.polygon = "Global_CostLine_HD_Polygon.shp" ,
file = "example.file.txt" , 
file.sep = "," ,
file.dec = "." ,
file.strucutre = 2 , 
file.header = FALSE ,
resolution = 0.01 ,
buffer = c(5,5,5,5) ,
export.file = TRUE   )

Authors

License

Except where otherwise noted, the content on this repository is licensed under a Creative Commons Attribution 4.0 International license.

Citation

Assis, J., Castilho Coelho, N., Alberto, F., Valero, M., Raimondi, P., Reed, D., … Serrão, E. A. (2013). High and Distinct Range-Edge Genetic Diversity despite Local Bottlenecks. PLoS ONE, 8(7), e68646. https://doi.org/10.1371/journal.pone.0068646