| Title: | Calculating Geographic Range from Occurrence Data |
|---|---|
| Description: | Calculates and analyzes six measures of geographic range from a set of longitudinal and latitudinal occurrence data. Measures included are minimum convex hull area, minimum spanning tree distance, longitudinal range, latitudinal range, maximum pairwise great circle distance, and number of X by X degree cells occupied. |
| Authors: | James Boyle Developer [aut, cre] |
| Maintainer: | James Boyle Developer <[email protected]> |
| License: | GPL-3 |
| Version: | 0.1.0 |
| Built: | 2026-11-08 22:53:12 UTC |
| Source: | https://github.com/cranhaven/cranhaven.r-universe.dev |
Occurrence data on bivalves from the Ypresian Data from the Paleobiology Database via the velociraptr package on May 17th, 2017
data(BivalvePBDB)data(BivalvePBDB)
A csv file
data(BivalvePBDB)data(BivalvePBDB)
Calculates degree x degree cell counts of a specified size
CellCount(longs, lats, CellSize = 5, longBounds = c(-180, 180), latBounds = c(-90, 90))CellCount(longs, lats, CellSize = 5, longBounds = c(-180, 180), latBounds = c(-90, 90))
longs |
- Array of longitudinal occurrence values in decimal degrees |
lats |
- Array of latitudinal occurrence values in decimal degrees |
CellSize |
- Size of each cell in degree X degree |
longBounds |
- Array of longitudinal boundaries in decimal degrees |
latBounds |
- Array of latitudinal boundaries in decimal degrees |
Returns the number of cells occupied, specified cell size, and coordinate list
This method uses grids cells constructed by equal degrees not area. So high latitude cells will have smaller areas than those at low latitude
longs<-c(22,55,-144) lats<-c(-12,22,-12) CellCount(longs,lats,CellSize=5,longBounds=c(-180,180),latBounds=c(-90,90))longs<-c(22,55,-144) lats<-c(-12,22,-12) CellCount(longs,lats,CellSize=5,longBounds=c(-180,180),latBounds=c(-90,90))
Performs Convex Hull area calculation
CHullArea(longs, lats)CHullArea(longs, lats)
longs |
- Array of longitudinal occurrence values in decimal degrees |
lats |
- Array of latitudinal occurrence values in decimal degrees |
Uses the cylindrical equal area projection in order to check if the minimum convex hull wraps around the prime meridian
Returns area of a set of coordinates
Relies on the 'sp' package for the Polygon and chull function
longs<-c(-12,23,55) lats<-c(34,22,30) CHullArea(longs,lats)longs<-c(-12,23,55) lats<-c(34,22,30) CHullArea(longs,lats)
Performs convex hull area calculation from coordinate sets on the Earth's surface
CHullAreaEarth(longs, lats)CHullAreaEarth(longs, lats)
longs |
- Longitudinal coordinates of occurrences in decimal degrees |
lats |
- Latitudinal coordinates of occurrences in decimal degrees |
Uses the cylindrical equal area projection in order to check if the minimum convex hull wraps around the prime meridian
Returns the convex hull area is square kilometers
Relies on the 'sp' package for the Polygon and chull function. Assumes latitude and longitude coordinates use the WGS84 datum
longs<-c(-133,-101,56) lats<-c(33,12,-2) CHullAreaEarth(longs,lats)longs<-c(-133,-101,56) lats<-c(33,12,-2) CHullAreaEarth(longs,lats)
Removes duplicate geographic locations and binds coordinates into a single element
CoordCollapse(longs, lats)CoordCollapse(longs, lats)
longs |
- Longitudinal coordinates of occurrences in decimal degrees |
lats |
- Latitudinal coordinates of occurrences in decimal degrees |
Returns a 2-column array of coordinates without any duplicate locations
Points are truncated to the hundredths place before checking for duplicates
longs<-c(34,133,-45) lats<-c(-12,44,76) CoordCollapse(longs,lats)longs<-c(34,133,-45) lats<-c(-12,44,76) CoordCollapse(longs,lats)
Creates an occurrence matrix of taxa by coordinates from the Paleobiology Database
CoordList_PBDB(pbdb_data)CoordList_PBDB(pbdb_data)
pbdb_data |
- Matrix of occurrence records from the Paleobiology Database, see downloadPBDB function in velociraptr package |
Cuts out records for which there is no paleogeographic information known
Returns a taxa by coordinates matrix of occurrences
See the velociraptr package for more details on downloading PBDB data
data(BivalvePBDB) CoordList_PBDB(BivalvePBDB)data(BivalvePBDB) CoordList_PBDB(BivalvePBDB)
Converts degrees to radians
deg2rad(deg)deg2rad(deg)
deg |
- decimal degree to be converted to radians |
Returns the degree in radians
[1]Originally from http://www.r-bloggers.com/great-circle-distance-calculations-in-r/
deg2rad(45)deg2rad(45)
Create a rectangular shaped distribution with equal area to a given area
EqualAreaRectangle(center = c(0, 0), TargetArea, error = 0.001)EqualAreaRectangle(center = c(0, 0), TargetArea, error = 0.001)
center |
- Arrary containing the coordinates of the center of circular portion of the rectangle in decimal degree |
TargetArea |
- Area in square kilometers desired for the rectangle |
error |
- The tolerable proportion of error between the rectangular shape and the TargetArea |
Returns a 2-dimensional array of decimal degree coordinates outlining a rectangular shaped distribution
This returns 100 evenly spaced points along each corner of the rectangle, in addition to the corners themselves
HorseShoeTest<-PtsAlgHorseShoe(z=2000,spacing=1,endAngles=c(-90,90)) HorseShoePts<-RandHorseShoe(center=c(0,0),npts=100,HorseShoeShape=HorseShoeTest) EqualAreaRectangle(TargetArea=as.numeric(HorseShoePts$TotalArea_km2),error=0.001)HorseShoeTest<-PtsAlgHorseShoe(z=2000,spacing=1,endAngles=c(-90,90)) HorseShoePts<-RandHorseShoe(center=c(0,0),npts=100,HorseShoeShape=HorseShoeTest) EqualAreaRectangle(TargetArea=as.numeric(HorseShoePts$TotalArea_km2),error=0.001)
Calculates the maximum pairwise great circle distance from a set of decimal degree coordinates
GCD(longs, lats)GCD(longs, lats)
longs |
- Longitudinal coordinates of occurrences in decimal degrees |
lats |
- Latitudinal coordinates of occurrences in decimal degrees |
Because this function does not account for the possibility that a taxa may wrap around more than half the Earth the maximum value is half the circumference of the Earth, approximately 20,038 kilometers.
Returns the maximum great circle distance in kilometers
The great circle distance can be extracted from the result of a minium spanning tree calcualation MSTDist() if available to avoid redundant calculations
longs<-c(34,156,-78) lats<-c(45,12,9) GCD(longs,lats)longs<-c(34,156,-78) lats<-c(45,12,9) GCD(longs,lats)
Calculates the geodesic distance between two points specified by latitude and longitude using the Haversine formula
gcd_hf(long1, lat1, long2, lat2)gcd_hf(long1, lat1, long2, lat2)
long1 |
- Longitudinal value of first point in decimal degrees |
lat1 |
- Latitudinal value of first point in decimal degrees |
long2 |
- Longitudinal value of second point in decimal degrees |
lat2 |
- Latitudinal value of second point in decimal degrees |
The Haversine formula can be inaccurate depending on coordinates
Returns the distance between two points on the Earth in kilometers
The haversine method is inaccuarate and should only be used when the vicenty formula fails or over very small distances
[1] Adapted from http://www.r-bloggers.com/great-circle-distance-calculations-in-r/
long1<-22 lat1<-44 long2<-52 lat2<-51 gcd_hf(long1,lat1,long2,lat2)long1<-22 lat1<-44 long2<-52 lat2<-51 gcd_hf(long1,lat1,long2,lat2)
Calculates the geodesic distance between two points specified by latitude/longitude using Vincenty inverse formula for ellipsoids
gcd_vif(long1, lat1, long2, lat2)gcd_vif(long1, lat1, long2, lat2)
long1 |
- Longitudinal value of first point in decimal degrees |
lat1 |
- Latitudinal value of first point in decimal degrees |
long2 |
- Longitudinal value of second point in decimal degrees |
lat2 |
- Latitudinal value of second point in decimal degrees |
Returns the distance between two points on the Earth in kilometers
[1] Adapted from http://www.r-bloggers.com/great-circle-distance-calculations-in-r/
long1<-22 lat1<-44 long2<-52 lat2<-51 gcd_vif(long1,lat1,long2,lat2)long1<-22 lat1<-44 long2<-52 lat2<-51 gcd_vif(long1,lat1,long2,lat2)
Function to calculate the correlation coefficient for pairwise comparisons between geographic range measures
GeoCor(GeoRange, Start = 1, method = "pearson")GeoCor(GeoRange, Start = 1, method = "pearson")
GeoRange |
- A matrix of taxa by geographic range calculations, as from the GeoRange_MultiTaxa function |
Start |
- The column index value where geographic range measures to be compared starts |
method |
- The correlation method to be used. See the cor() function for available inputs |
Returns a sparse pairwsie matrix of correlation coefficients
The correlation calculation uses the "pairwise.complete.obs" option from the cor function so that only complete pairs of observations are used, pairs containing an NA are ignored
See the velociraptr package for details of the downloadPBDB() function
## Not run: data(BivalvePBDB) BivalveMatrix<-CoordList_PBDB(BivalvePBDB) testBivalve<-GeoRange_MultiTaxa(OccMatrix=BivalveMatrix,TaxaStart=3) GeoCor(testBivalve,Start=1,method="kendall") ## End(Not run)## Not run: data(BivalvePBDB) BivalveMatrix<-CoordList_PBDB(BivalvePBDB) testBivalve<-GeoRange_MultiTaxa(OccMatrix=BivalveMatrix,TaxaStart=3) GeoCor(testBivalve,Start=1,method="kendall") ## End(Not run)
Function to calculate the skewness and coefficient of variance for a set of geographic range calculations
GeoPerformance_SkewCV(GeoRange)GeoPerformance_SkewCV(GeoRange)
GeoRange |
- Data matrix containing the geographic range calculations for a set of taxa, as from the GeoRange_MultiTaxa() function |
Returns a list of the skewness and coefficient of variance for each geographic range measure
The coefficient of variance returned is standard deviation/mean
See the raster and moments packages for more details on the calculation of skewness and coefficient of variance
## Not run: data(BivalvePBDB) BivalveMatrix<-CoordList_PBDB(BivalvePBDB) BivalveGeo<-GeoRange_MultiTaxa(OccMatrix=BivalveMatrix,TaxaStart=3) GeoPerformance_SkewCV(BivalveGeo) ## End(Not run)## Not run: data(BivalvePBDB) BivalveMatrix<-CoordList_PBDB(BivalvePBDB) BivalveGeo<-GeoRange_MultiTaxa(OccMatrix=BivalveMatrix,TaxaStart=3) GeoPerformance_SkewCV(BivalveGeo) ## End(Not run)
Function to tabulate number of occurrences/locations, six geographic range measures, minimum and maximum latitude and longitude for each taxon in a dataset
GeoRange_MultiTaxa(OccMatrix, TaxaStart, LongPos = 1, LatPos = 2, CellSize = 5, longBounds = c(-180, 180), latBounds = c(-90, 90))GeoRange_MultiTaxa(OccMatrix, TaxaStart, LongPos = 1, LatPos = 2, CellSize = 5, longBounds = c(-180, 180), latBounds = c(-90, 90))
OccMatrix |
- A matrix where columns are taxon occurrences and also having at least longitude and latitude values |
TaxaStart |
- The column index value where taxon records start |
LongPos |
- The column index value of longitudinal coordinates in the OccMatrix |
LatPos |
- The column index value of latitudinal coordinates in the OccMatrix |
CellSize |
- The size of each cell in degree X degree |
longBounds |
- Array of longitudinal boundaries in decimal degrees |
latBounds |
- Array of latitudinal boundaries in decimal degrees |
Returns a matrix of taxa by geographic range measures, including number of observations, number of unique locations observed at, minimum spanning tree distance, minimum convex hull area, maximum pairwise great circle distance, latitudinal range, longitudinal range, and number of degree X degree cells occupied
Calculates the number of observations, localities, minimum spanning tree distance, convex hull area, longitudinal range, latitudinal range, and cell count
See the velociraptr package for details of the downloadPBDB() function
## Not run: data(BivalvePBDB) BivalveMatrix<-CoordList_PBDB(BivalvePBDB) GeoRange_MultiTaxa(OccMatrix=BivalveMatrix,TaxaStart=3) ## End(Not run)## Not run: data(BivalvePBDB) BivalveMatrix<-CoordList_PBDB(BivalvePBDB) GeoRange_MultiTaxa(OccMatrix=BivalveMatrix,TaxaStart=3) ## End(Not run)
Calculates six geographic range measures at resampled a number of time from specified sample sizes
GeoRarefaction_MultiTaxa(nLocCut = 3, OccMatrix, TaxaStart, LongPos = 1, LatPos = 2, iter = 10, CellSize = 5, longBounds = c(-180, 180), latBounds = c(-90, 90), steps = c(1, 50, 40, 30, 20, 10, 5), replacePts = FALSE)GeoRarefaction_MultiTaxa(nLocCut = 3, OccMatrix, TaxaStart, LongPos = 1, LatPos = 2, iter = 10, CellSize = 5, longBounds = c(-180, 180), latBounds = c(-90, 90), steps = c(1, 50, 40, 30, 20, 10, 5), replacePts = FALSE)
nLocCut |
- The minimum number of locations a taxon must be seen at to have geographic range measures calculated |
OccMatrix |
- A matrix where columns are taxon occurrences and also having at least longitude and latitude values |
TaxaStart |
- The column index value where taxon records start |
LongPos |
- The column index value of longitudinal coordinates in the OccMatrix |
LatPos |
- The column index value of latitudinal coordinates in the OccMatrix |
iter |
- The number of times a taxon's locations are resampled at each step size |
CellSize |
- The size of each cell in degree X degree |
longBounds |
- Array of longitudinal boundaries in decimal degrees |
latBounds |
- Array of latitudinal boundaries in decimal degrees |
steps |
- Array of the values representing the number of points to be subsampled for each taxon |
replacePts |
- A logical value indicating whether points are allowed to be sampled more than once during each subsampling iteration |
The nLocCut parameter is the minimum number of distinct geographic locations a taxon must be observed at to have geographic range measures calcualted, if below retruns NA. The steps parameter typically begins with a 1 representing that all points should be used in calculations but this is not required. The replacePts parameter must be set to TRUE if any of the steps require a greater number of points to be sampled than there are actual locations for a taxon, otherwise the function will fail.
Returns a vector where each element is a taxon with a list of each geographic range measure as a separate matrix of values. Measures include minimum spanning tree distance, minimum convex hull area, maxmimum pairwise great circle distance, latitudinal range, longitudinal range, and number of degree X degree cells occupied.
If PEE values are to be calculated as a next step the steps parameter needs to have a value of 1 as its first value
See the velociraptr package for details of the downloadPBDB() function
## Not run: data(BivalvePBDB) BivalveMatrix<-CoordList_PBDB(BivalvePBDB) GeoRarefaction_MultiTaxa(nLocCut=20,OccMatrix=BivalveMatrix,TaxaStart=3,replacePts=TRUE) ## End(Not run)## Not run: data(BivalvePBDB) BivalveMatrix<-CoordList_PBDB(BivalvePBDB) GeoRarefaction_MultiTaxa(nLocCut=20,OccMatrix=BivalveMatrix,TaxaStart=3,replacePts=TRUE) ## End(Not run)
Calculates six geographic range measures at specified sample sizes for a single taxon
GeoRarefaction_SingleTaxon(TName = "Bird1", OccMatrix, LongPos = 1, LatPos = 2, iter = 10, CellSize = 5, longBounds = c(-180, 180), latBounds = c(-90, 90), steps = c(1, 50, 40, 30, 20, 10, 5), replacePts = FALSE)GeoRarefaction_SingleTaxon(TName = "Bird1", OccMatrix, LongPos = 1, LatPos = 2, iter = 10, CellSize = 5, longBounds = c(-180, 180), latBounds = c(-90, 90), steps = c(1, 50, 40, 30, 20, 10, 5), replacePts = FALSE)
TName |
- The name of the taxon of interest, as labeled in OccMatrix, as a string |
OccMatrix |
- A matrix where columns are taxon occurrences and also having at least longitude and latitude values |
LongPos |
- The column index value of longitudinal coordinates in the OccMatrix |
LatPos |
- The column index value of latitudinal coordinates in the OccMatrix |
iter |
- The number of times a taxon's locations are resampled at each step size |
CellSize |
- The size of each cell in degree X degree |
longBounds |
- Array of longitudinal boundaries in decimal degrees |
latBounds |
- Array of latitudinal boundaries in decimal degrees |
steps |
- Array of the values representing the number of points to be subsampled for each taxon |
replacePts |
- A logical value indicating whether points are allowed to be sampled more than once during each subsampling iteration |
The nLocCut parameter is the minimum number of distinct geographic locations a taxon must be observed at to have geographic range measures calcualted, if below retruns NA. The steps parameter typically begins with a 1 representing that all points should be used in calculations but this is not required. The replacePts parameter must be set to TRUE if any of the steps require a greater number of points be locations be sampled than are available for a taxon, otherwise the function will fail.
Returns a list of each geographic range measure as a separate matrix of values. Measures include minimum spanning tree distance, minimum convex hull area, maximum pairwise great circle distance, latitudinal range, longitudinal range, and number of degree X degree cells occupied.
If PEE values are to be calculated as a next step the steps parameter needs to have a value of 1 as its first value
## Not run: data(BivalvePBDB) BivalveMatrix<-CoordList_PBDB(BivalvePBDB) GeoRarefaction_SingleTaxon(TName=names(BivalveMatrix)[3],OccMatrix=BivalveMatrix,replacePts=TRUE) ## End(Not run)## Not run: data(BivalvePBDB) BivalveMatrix<-CoordList_PBDB(BivalvePBDB) GeoRarefaction_SingleTaxon(TName=names(BivalveMatrix)[3],OccMatrix=BivalveMatrix,replacePts=TRUE) ## End(Not run)
Prints Hello, world!
hello()hello()
Prints 'Hello, world!
Function to calcuate the area of a given horseshoe shape
HorseShoeArea(HorseShoeShape)HorseShoeArea(HorseShoeShape)
HorseShoeShape |
- Object containing the outline of a horseshoe shape, output from PtsAlgHorseShoe function |
Returns the area of the horseshoe shape with the circular and rectangular portions separated
Currently forces use of a height 5/4 width and r2=2*r1 of origin (center)
[1] From http://mathforum.org/library/drmath/view/51816.html
HorseShoeTest<-PtsAlgHorseShoe(z=2000,spacing=1,endAngles=c(-90,90)) HorseShoeArea(HorseShoeTest)HorseShoeTest<-PtsAlgHorseShoe(z=2000,spacing=1,endAngles=c(-90,90)) HorseShoeArea(HorseShoeTest)
Calculates the latitudinal range in degrees and kilometers
LatRg(lats)LatRg(lats)
lats |
- Latitudinal occurrences in decimal degrees |
Returns the outermost coordinates of the set, the latitudinal span in degrees and in kilometers
lats<-c(-23,56,-2,45,66) LatRg(lats)lats<-c(-23,56,-2,45,66) LatRg(lats)
Calculates the longitudinal range in degrees and kilometers, assuming a latitude of 45 degrees for all points by default. Accounts for the possibility of wrapping around the globe.
LongRg(longs, lats = 45)LongRg(longs, lats = 45)
longs |
- Longitudinal occurrences in decimal degrees |
lats |
- A single value representing the latitude to calculate longitudinal distance from or a list of latitudinal coordinates in decimal degrees |
Calculates the longitudinal range as 360-largest longitudinal gap and accounts for the possbility that a taxon's range wraps around the prime meridian
Returns the outermost coordinates of the set, the longitudinal span in degrees and in kilometers
longs<-c(133,76,-77,7,-80) lats<-c(45) LongRg(longs)longs<-c(133,76,-77,7,-80) lats<-c(45) LongRg(longs)
Calculates the minimum spanning tree distance, in kilometers, using Prim's Algorithm [1]
MSTDist(longs, lats)MSTDist(longs, lats)
longs |
- Longitudinal occurrences in decimal degrees |
lats |
- Latitudinal occurrences in decimal degrees |
Uses Prim's algorithm for finding the minimum spanning tree, time-consuming calculation as the number of locations increases past 1000
Returns the minimum spanning tree distance in kilometers, the pairwise distance matrix of occurrences, the order points were connected in, and a 2-column array of coordinates
[1] Prim, R.C. 1957. Shortest Connection Networks and Some Generalizations. The Bell System Technical Journal 36:1389-1401.
longs<-c(12,34,-55) lats<-c(-41,3,56) MSTDist(longs,lats)longs<-c(12,34,-55) lats<-c(-41,3,56) MSTDist(longs,lats)
Calculates the minimum spanning tree distance, in kilometers, using Prim's Algorithm [1] and a previously calculated pairwsie distance matrix
MSTDist_FromMat(longs, lats, DistMat)MSTDist_FromMat(longs, lats, DistMat)
longs |
- Longitudinal occurrences in decimal degrees |
lats |
- Latitudinal occurrences in decimal degrees |
DistMat |
- Pairwsie distance matrix of coordinates, from the PWMatrix() function |
Uses Prim's algorithm for finding the minimum spanning tree
Returns the minimum spanning tree distance in kilometers, the pairwise distance matrix of occurrences, the order points were connected in, and a 2-column array of coordinates
[1] Prim, R.C. 1957. Shortest Connection Networks and Some Generalizations. The Bell System Technical Journal 36:1389-1401.
MSTCalc<-MSTDist(longs=c(22,44,-12,67),lats=c(-77,56,22,56)) MSTDist_FromMat(MSTCalc$Longitude,MSTCalc$Latitude,MSTCalc$MST_DistMat)MSTCalc<-MSTDist(longs=c(22,44,-12,67),lats=c(-77,56,22,56)) MSTDist_FromMat(MSTCalc$Longitude,MSTCalc$Latitude,MSTCalc$MST_DistMat)
Function to compile the PBDB_PEE_SingleTaxon output for a list of taxa
PEE_MultiTaxa(GeoRare_Multi)PEE_MultiTaxa(GeoRare_Multi)
GeoRare_Multi |
- The list of geographic range measures calculated from the GeoRarefaction_MultiTaxa function |
Returns a vector list of six geographic range measures matrix with percent error of estimates [1] for each value
[1] Russell, M.P. & D.R. Lindberg. 1988. Real and Random Patterns Associated with Molluscan Spatial and Temporal Distributions. Paleobiology 14:322-330.
See the velociraptr package for details of the downloadPBDB() function
## Not run: data(BivalvePBDB) BivalveMatrix<-CoordList_PBDB(BivalvePBDB) BivalveGeo<-GeoRarefaction_MultiTaxa(nLocCut=20,OccMatrix=BivalveMatrix,TaxaStart=3,replacePts=TRUE) PEE_MultiTaxa(BivalveGeo) ## End(Not run)## Not run: data(BivalvePBDB) BivalveMatrix<-CoordList_PBDB(BivalvePBDB) BivalveGeo<-GeoRarefaction_MultiTaxa(nLocCut=20,OccMatrix=BivalveMatrix,TaxaStart=3,replacePts=TRUE) PEE_MultiTaxa(BivalveGeo) ## End(Not run)
Function to calculate PEE [1] matrices for all the geographic range measures
PEE_SingleTaxon(GeoRare, TName = "Brach 1")PEE_SingleTaxon(GeoRare, TName = "Brach 1")
GeoRare |
- The list of geographic range measures calculated from the GeoRarefaction_SingleTaxon or GeoRarefaction_MultiTaxa functions |
TName |
- Name of the target taxon for analysis as a string |
Returns a list of six geographic range measures matrix with percent error of estimates for each value
[1] Russell, M.P. & D.R. Lindberg. 1988. Real and Random Patterns Associated with Molluscan Spatial and Temporal Distributions. Paleobiology 14:322-330.
See the velociraptr package for details of the downloadPBDB() function
## Not run: data(BivalvePBDB) BivalveMatrix<-CoordList_PBDB(BivalvePBDB) BivalveGeo<-GeoRarefaction_MultiTaxa(nLocCut=50,OccMatrix=BivalveMatrix,TaxaStart=3,iter=20) PEE_SingleTaxon(GeoRare=BivalveGeo,TName=names(BivalveGeo)[3]) ## End(Not run)## Not run: data(BivalvePBDB) BivalveMatrix<-CoordList_PBDB(BivalvePBDB) BivalveGeo<-GeoRarefaction_MultiTaxa(nLocCut=50,OccMatrix=BivalveMatrix,TaxaStart=3,iter=20) PEE_SingleTaxon(GeoRare=BivalveGeo,TName=names(BivalveGeo)[3]) ## End(Not run)
Plots the measured value versus rarefied samples or percent error of estimates (PEE) of a rarefied samples for a geographic range measure
Plot_Rarefaction(Mes1_AllTaxa, Mes2_AllTaxa, symbol = 20, measure = 2, SampSize = 1, color = "black")Plot_Rarefaction(Mes1_AllTaxa, Mes2_AllTaxa, symbol = 20, measure = 2, SampSize = 1, color = "black")
Mes1_AllTaxa |
- Vector list of measured values for multiple taxa, from the GeoRarefaction_MultiTaxa function, or PEE calculations for multiple taxa, from from PEE_MultiTaxa function |
Mes2_AllTaxa |
- Vector list of measured values for multiple taxa, output from GeoRarefaction_MultiTaxa function |
symbol |
- Symbol used for plotting, as per pch graphical parameter |
measure |
- Specifies which measure to be plotted, 2=MST 3=CH 4=GCD 5=LatRg 6=LongRg 7=CellCount |
SampSize |
- Specifies the index value of the rarefaction sample size from the PEE_AllTaxa parameter |
color |
- Specifies the color of symbols being plotted |
For each taxon for a specific geographic range measure using 95 Measure paramter is the ordinal position of the measure of interest 2=MST,3=CH,4=GCD,5=LatRg,6=LongRg,7=CellCount SampSize parameter indicates the index column position of steps size, default is first column (all points)
Returns a plot of measured geographic range values or PEE versus true value for a specific geographic range measure at varying sample sizes
## Not run: data(BivalvePBDB) BivalveMatrix<-CoordList_PBDB(BivalvePBDB) BivalveGeo<-GeoRarefaction_MultiTaxa(nLocCut=20,OccMatrix=BivalveMatrix,TaxaStart=3,replacePts=TRUE) BivalvePEE<-PEE_MultiTaxa(BivalveGeo) Plot_Rarefaction(BivalvePEE,BivalveGeo,symbol=20,measure=2,SampSize=2) ## End(Not run)## Not run: data(BivalvePBDB) BivalveMatrix<-CoordList_PBDB(BivalvePBDB) BivalveGeo<-GeoRarefaction_MultiTaxa(nLocCut=20,OccMatrix=BivalveMatrix,TaxaStart=3,replacePts=TRUE) BivalvePEE<-PEE_MultiTaxa(BivalveGeo) Plot_Rarefaction(BivalvePEE,BivalveGeo,symbol=20,measure=2,SampSize=2) ## End(Not run)
Plots the minimum convex hull of a set of coordinates
PlotConvexHull(xcoord, ycoord, lcolor = "blue")PlotConvexHull(xcoord, ycoord, lcolor = "blue")
xcoord |
- Array of x-coordinates or longitudinal values |
ycoord |
- Array of y-coordinates or latitudinal values |
lcolor |
- String or integer value indicating the color of the convex hull boundary lines |
Plots a minimum convex hull
This function does not account for the possibility of points crossing the prime meridian and in cases where this occurs the convex hull shown will be incorrect
longs<-c(20,20,40,40) lats<-c(-5,5,-5,5) PlotConvexHull(xcoord=longs,ycoord=lats)longs<-c(20,20,40,40) lats<-c(-5,5,-5,5) PlotConvexHull(xcoord=longs,ycoord=lats)
Plots the minimum spanning tree of a set of coordinates
PlotMST(MSTCalc, color = "black", symbol = 16, xlimit = "NA", ylimit = "NA")PlotMST(MSTCalc, color = "black", symbol = 16, xlimit = "NA", ylimit = "NA")
MSTCalc |
- Output from the MSTDist function |
color |
- Color of the lines connecting point |
symbol |
- Symbol value for the pch graphical parameter for plotting coordinates |
xlimit |
- Array of values denoting the x-axis limits |
ylimit |
- Array of values denoting the y-axis limits |
Plots a minimum spanning tree
If the xlimit and ylimit parameters are left to their default values the axis ranges are based on the minimum and maximum values of the coordinates This function does not account for the possibility of points crossing the prime meridian and in cases where this occurs lines will cut across the entire plot
w<-MSTDist(longs=c(23,78,-23,56),lats=c(21,4,55,-3)) PlotMST(MSTCalc=w)w<-MSTDist(longs=c(23,78,-23,56),lats=c(21,4,55,-3)) PlotMST(MSTCalc=w)
Function to find points along a horseshoe shape
PtsAlgHorseShoe(z, spacing = 1, endAngles = c(-90, 90))PtsAlgHorseShoe(z, spacing = 1, endAngles = c(-90, 90))
z |
- Distance in kilometers from the center of the horseshoe to its lower boundary |
spacing |
- Degrees between successive point outlining the horseshoe shape |
endAngles |
- Array of values denoting the degree of rotation for the circular part of the horseshoe distribution |
Currently forces use 0,0 as the center, a height 5/4 width, and r2=2*r1 of origin (center)
Returns a 2-dimensional array of decimal degree coordinates outlining a horseshoe shape
Currently only works when endAngles are multiples of -90,90; otherwise rectangle point positions are off
[1] From http://mathforum.org/library/drmath/view/51816.html
PtsAlgHorseShoe(z=2000,spacing=1,endAngles=c(-90,90))PtsAlgHorseShoe(z=2000,spacing=1,endAngles=c(-90,90))
Creates a sparse pairwise distance matrix of a coordinate set
PWMatrix(Coords)PWMatrix(Coords)
Coords |
- Two-dimensional array of longitudinal and latitudinal coordinates output from CoordCollapse() function |
Returns a sparse pairwise distance matrix of great circle distances between pairs of points
longs<-runif(10,-22,33) lats<-runif(10,-22,33) Coords<-CoordCollapse(longs,lats) PWMatrix(Coords)longs<-runif(10,-22,33) lats<-runif(10,-22,33) Coords<-CoordCollapse(longs,lats) PWMatrix(Coords)
Function to randomly generate points within a horseshoe-shape
RandHorseShoe(center = c(0, 0), npts = 100, HorseShoeShape, HRatio = 1.5, RadRatio = 0.5)RandHorseShoe(center = c(0, 0), npts = 100, HorseShoeShape, HRatio = 1.5, RadRatio = 0.5)
center |
- Arrary containint the coordinates of the center of circular portion of the horseshoe in decimal degrees |
npts |
- Integer value indicating the number of points to generate within the horseshoe shape |
HorseShoeShape |
- Object containing the outline of a horseshoe shape, output from PtsAlgHorseShoe function |
HRatio |
- The ratio of the lower rectangle portions of the horseshoe to the outer radius of the circular portion of the horseshoe |
RadRatio |
- The ration of the of the outer to inner radius of the circular part of the horseshoe shape |
Returns a 2-dimensional array of decimal degree coordinates within the horseshoe shape and the total area of the shape
HRatio Currently defaults to 3/2 per the PtsAlgHorseShoe() function RadRatio currently defaults to 1/2 per the PtsAlgHorseShoe() function Center currently defaults to c(0,0) as this is always the center of the PtsAlgHorseShoe() function currently Function currently does not take acount of the decreasing surface area moving toward the poles so points closer to the poles will be overrepresented relative to the actual surface area they represent
HorseShoeTest<-PtsAlgHorseShoe(z=2000,spacing=1,endAngles=c(-90,90)) RandHorseShoe(center=c(0,0),npts=100,HorseShoeShape=HorseShoeTest)HorseShoeTest<-PtsAlgHorseShoe(z=2000,spacing=1,endAngles=c(-90,90)) RandHorseShoe(center=c(0,0),npts=100,HorseShoeShape=HorseShoeTest)
Function to randomly generate points within a given rectangular shaped distribution
RandRec(RecShape, npts = 100)RandRec(RecShape, npts = 100)
RecShape |
- The outline of a rectangular distribution output from the EqualAreaRectangle() function |
npts |
- The number of randomly generated points within the rectangular shape |
Returns a 2-dimensional array of decimal degree coordinates within a rectangular shape
Function currently does not take acount of the decreasing surface area moving toward the poles so points closer to the poles will be overrepresented relative to the actual surface area they represent
HorseShoeTest<-PtsAlgHorseShoe(z=2000,spacing=1,endAngles=c(-90,90)) HorseShoePts<-RandHorseShoe(center=c(0,0),npts=100,HorseShoeShape=HorseShoeTest) RecOutline<-EqualAreaRectangle(TargetArea=as.numeric(HorseShoePts$TotalArea_km2),error=0.001) RandRec(RecShape=RecOutline,npts=100)HorseShoeTest<-PtsAlgHorseShoe(z=2000,spacing=1,endAngles=c(-90,90)) HorseShoePts<-RandHorseShoe(center=c(0,0),npts=100,HorseShoeShape=HorseShoeTest) RecOutline<-EqualAreaRectangle(TargetArea=as.numeric(HorseShoePts$TotalArea_km2),error=0.001) RandRec(RecShape=RecOutline,npts=100)