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

map.sel.polyR Documentation

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 or list returned by plotmap

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

Details

map.sel.poly is a convenience wrapper for plotmap, sel.poly, and point.in.polygon. For custiomized plotting, the plot can be produced by plotmap, plotvoronoi or levelplot, and the result of that plot command handed over to map.sel.poly, see the example below.

If even more customized plotting is required,sel.poly should be used (see example).

Value

map.sel.poly: array of indices for points within the selected polygon

sel.poly: n x 2 matrix with the corner points of the polygon

Author(s)

Claudia Beleites, Sebastian Mellor

Claudia Beleites

See Also

grid.locator, map.identify

grid.locator

Examples

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

## customized version
data <- sample (chondro [,, 1004 - 2i ~ 1004 + 2i], 300)

plotdata <- plotvoronoi (data, clusters ~ y * x, col.regions = alois.palette ())
print (plotdata)
map.sel.poly (plotdata)

## even more customization:
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"))
}

hyperSpec documentation built on May 29, 2024, 7:28 a.m.