Learn R Programming

hyperSpec (version 0.98-20150304)

map.sel.poly: Interactively select a polygon (grid graphics) and highlight points

Description

Click the points that should be connected as polygon. Input ends with right click (see grid.locator). Polygon will be drawn closed.

Usage

map.sel.poly(data, pch = 19, size = 0.3, ...)
sel.poly(pch = 19, size = 0.3, ...)

Arguments

data
hyperSpec object for plotting map
pch
symbol to display the points of the polygon for sel.poly
size
size for polygon point symbol for sel.poly
...
further arguments for grid.points and grid.lines

Value

map.sel.poly: array of indices for points within the selected polygonsel.poly: n x 2 matrix with the corner points of the polygon

Details

map.sel.poly is a convenience wrapper for plotmap, sel.poly, and point.in.polygon. If more customized plotting is required, sel.poly should be used (see example).

See Also

grid.locator, map.identify

grid.locator

Examples

Run this code
if (interactive ()){
## convenience wrapper
map.sel.poly (chondro)

## customized version
data <- sample (chondro, 300)

## plot as needed
plotvoronoi (data)

## interactively retrieve polygon
polygon <- sel.poly ()

## find data points within polygon
require ("sp")
i.sel <- which (point.in.polygon (data$x, data$y, polygon [, 1], polygon [, 2]) > 0)

## work with selected points
grid.points (unit (data$x [i.sel], "native"), unit (data$y [i.sel], "native"))
}

Run the code above in your browser using DataLab