Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

makepoly

Add vertices to a polygon or line


Description

Make a polygon or line by adding intermedate points (vertices) on the great circles inbetween the points supplied. This can be relevant when vertices are relatively far apart. It can make the shape of the object to be accurate, when plotted on a plane. makePoly will also close the polygon if needed.

Usage

makePoly(p, interval=10000, sp=FALSE, ...)
makeLine(p, interval=10000, sp=FALSE, ...)

Arguments

p

a 2-column matrix (longitude/latitude) or a SpatialPolygons or SpatialLines object

interval

maximum interval of points, in units of r

sp

Logical. If TRUE, a SpatialPolygons object is retunred (depends on the 'sp' package)

...

additional arguments passed to distGeo

Value

A matrix

Author(s)

Robert J. Hijmans

Examples

pol <- rbind(c(-180,-20), c(-160,5), c(-60, 0), c(-160,-60), c(-180,-20))
plot(pol)
lines(pol, col='red', lwd=3)
pol2 = makePoly(pol, interval=100000)
lines(pol2, col='blue', lwd=2)

geosphere

Spherical Trigonometry

v1.5-10
GPL (>= 3)
Authors
Robert J. Hijmans [cre, aut], Ed Williams [ctb], Chris Vennes [ctb]
Initial release
2019-05-25

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.