lets.midpoint {letsR} | R Documentation |
Compute the midpoint of species' geographic ranges
Description
Calculate species distribution midpoint from a presence-absence matrix using several methods.
Usage
lets.midpoint(pam, planar = FALSE, method = "PC", inside = FALSE)
Arguments
pam |
A presence-absence |
planar |
Logical, if |
method |
Default option, "PC" (polygon centroid) will generate a polygon
from the raster, and calculate the centroid of this polygon based on the
function |
inside |
logical. If TRUE the points returned are guaranteed to be inside the polygons or on the lines, but they are not the true centroids. True centroids may be outside a polygon, for example when a polygon is "bean shaped", and they are unlikely to be on their line |
Value
A data.frame
containing the species' names and geographic
coordinates (longitude [x], latitude [y]) of species' midpoints.
Author(s)
Fabricio Villalobos & Bruno Vilela
See Also
Examples
## Not run:
data(PAM)
mid <- lets.midpoint(PAM, method = "PC")
mid2 <- lets.midpoint(PAM, method = "GM")
mid3 <- lets.midpoint(PAM, method = "CMD")
mid4 <- lets.midpoint(PAM, method = "MCC")
mid5 <- lets.midpoint(PAM, method = "PC", planar = TRUE)
mid6 <- lets.midpoint(PAM, method = "GM", planar = TRUE)
mid7 <- lets.midpoint(PAM, method = "CMD", planar = TRUE)
mid8 <- lets.midpoint(PAM, method = "MCC", planar = TRUE)
for (sp in seq_len(nrow(mid))) {
#sp = 4 # Or choose a line or species
plot(PAM, name = mid[sp, 1])
points(mid[sp, -1], col = adjustcolor("blue", .8), pch = 20, cex = 1.5)
points(mid2[sp, -1], col = adjustcolor("green", .8), pch = 20, cex = 1.5)
points(mid3[sp, -1], col = adjustcolor("yellow", .8), pch = 20, cex = 1.5)
points(mid4[sp, -1], col = adjustcolor("purple", .8), pch = 20, cex = 1.5)
points(mid5[sp, -1], col = adjustcolor("orange", .8), pch = 20, cex = 1.5)
points(mid6[sp, -1], col = adjustcolor("black", .8), pch = 20, cex = 1.5)
points(mid7[sp, -1], col = adjustcolor("gray", .8), pch = 20, cex = 1.5)
points(mid8[sp, -1], col = adjustcolor("brown", .8), pch = 20, cex = 1.5)
Sys.sleep(1)
}
## End(Not run)