linesegments | R Documentation |
Accepts vectors of x and y values of pairs of points (e.g., longitude and latitude), reformats them and adds line segments to an existing plot. Each line segment drawn connects one point its paired point. The two sets of points have to be equal in length, set up as pairs.
linesegments(xfrom, yfrom, xto, yto, ...)
xfrom |
required numeric vector of x values for starting points |
yfrom |
required numeric vector of y values for starting points |
xto |
required numeric vector of x values for ending points |
yto |
required numeric vector of y values for ending points |
... |
optional additional parameters to pass to |
This function also silently returns a matrix of two columns.
Each column is a vector that has elements sequenced in groups of three –
the from point, then the to point, then NA to signify a break in line drawing. See lines
Draws lines(), one line segment from each starting point to its corresponding ending point.
testpoints
and get.nearest
t10 <- testpoints(10, minlat = 25, maxlat = 45, minlon = -100, maxlon = -60)
t100 <- testpoints(100, minlat = 25, maxlat = 45, minlon = -100, maxlon = -60)
nears=as.data.frame( get.nearest(t10, t100, return.latlons=TRUE) )
plot(t10)
plot(t100, pch='.')
linesegments(nears$fromlon, nears$fromlat, nears$tolon, nears$tolat)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.