Learn R Programming

swfscMisc (version 1.6.5)

circle.polygon: Circle Polygon (on Earth)

Description

Creates a circular polygon (optionally on the earth) centered at a given point with a constant radius.

Usage

circle.polygon(
  x,
  y,
  radius,
  brng.limits = 0,
  sides = 1,
  by.length = TRUE,
  units = "nm",
  ellipsoid = datum(),
  dist.method = "lawofcosines",
  destination.type = "ellipsoid",
  poly.type = "cart.earth"
)

Value

A matrix representing the desired circle polygon centered at lat, lon of radius.

Arguments

x, y

number specifying the coordinates of the center of the circle in decimal degrees. If poly.type is "simple.earth" or "complex.earth", this will be longitude and latitude respectively.

radius

radius of sphere.

brng.limits

number, or vector of two numbers. If one value is given, it is used as the starting bearing in degrees for the first point of the circle. If a vector of two values is given, then they are used as the start and end bearings of arc.

sides

number that represents either length of sides or number of sides, as specified by the 'by.length' argument.

by.length

logical. If TRUE, then sides is the length of sides, if FALSE, then sides is number of sides.

units

character for units of distance: Can be "km" (kilometers), "nm" (nautical miles), "mi" (statute miles).

ellipsoid

ellipsoid model parameters as returned from a call to datum.

dist.method

character specifying method for calculating distance for type = "cart.earth". See method argument of distance for more information.

destination.type

character specifying type of surface for type = "gc.earth". See type argument of destination for more information.

poly.type

character specifying the type of polygon calculation to use. Can be one of "cartesian" using basic cartesian coordinates, "cart.earth" for a simple polygon on the earth's surface treating latitude and longitude as cartesian coordinates, or "gc.earth" for a more precise calculation keeping a constant great-circle radius.

Author

Eric Archer eric.archer@noaa.gov

Examples

Run this code
cart.earth <- circle.polygon(-117.24, 32.86, 40, poly.type = "cart.earth")

lat.range <- c(32, 34)
lon.range <- c(-118.5, -116)

op <- par(mar = c(3, 5, 5, 5) + 0.1, oma = c(1, 1, 1, 1))

plot.new()
plot.window(xlim = lon.range, ylim = lat.range)
points(-117.24, 32.86, pch = 19, col = "red")
polygon(cart.earth, border = "red", lwd = 3)
lat.lon.axes(n = 3)
box(lwd = 2)
mtext("poly.type = 'cart.earth'", line = 3)

par(op)

Run the code above in your browser using DataLab