sl.boundingcircle: Find a (Small) Bounding Circle For a Set of Points on a...

View source: R/sl.boundingcircle.R

sl.boundingcircleR Documentation

Find a (Small) Bounding Circle For a Set of Points on a Sphere

Description

Find a bounding circle for a set of points on a sphere. Ideally, this would be the smallest possible of such circles, but currently only a fast approximate method ('Ritter') is implemented which provides a bounding circle that is typically 5-20% larger than the smallest possible.

Usage

sl.boundingcircle(lon=NULL, lat=NULL, method="ritter", verbose=TRUE)

Arguments

lon

a numeric vector specifying the longitudes of the points to be enclosed.

lat

a numeric vector specifying the latitudes of the points to be enclosed.

method

a character specifying the method to be used; currently only 'ritter' is implemented which is fast but provides a bounding circle that is typically 5-20% larger than the smallest possible.

verbose

a logical value specifying whether or not to warn about the approximate 'Ritter' method.

Value

center_lon

central longitude of the bounding circle

center_lat

central latitude of the bounding circle

radius

radius of the bounding circle (in degrees)

Author(s)

Helge Goessling

Examples

lons = rnorm(10)*20 + 30
lats = rnorm(10)*20 - 20
bounding.circ = sl.boundingcircle(lon = lons, lat = lats)

pir = sl.plot.init(projection="lonlat",do.init.device=FALSE)
res = sl.plot.naturalearth(pir,resolution="coarse")
sl.plot.points(pir,lons,lats,col="blue")
circ = sl.circle(lon = bounding.circ$center_lon, lat = bounding.circ$center_lat, radius = bounding.circ$radius)
sl.plot.lines(pir,circ$lon,circ$lat,col="red")
sl.plot.end(pir,do.close.device=FALSE)

# Can also be used to determine automatically which part of the map to plot in 'polar' projection, for example (re-using the points and their bounding circle used above):
pir = sl.plot.init(projection="polar",polar.lonlatrot=c(bounding.circ$center_lon,bounding.circ$center_lat,0),polar.latbound=(90-1.1*(bounding.circ$radius)),do.init.device=FALSE)
res = sl.plot.naturalearth(pir,resolution="coarse")
res = sl.plot.lonlatgrid(pir,labels=TRUE)
sl.plot.points(pir,lons,lats,col="blue")
sl.plot.end(pir,do.close.device=FALSE)


helgegoessling/spheRlab documentation built on April 8, 2024, 8:34 a.m.