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

Description Usage Arguments Details Value Author(s) See Also Examples

Description

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

Usage

1
2
3
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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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"))
}

Example output

Loading required package: lattice
Loading required package: grid
Loading required package: ggplot2
Package hyperSpec, version 0.99-20180627

To get started, try
   vignette ("hyperspec")
   package?hyperSpec 
   vignette (package = "hyperSpec")

If you use this package please cite it appropriately.
   citation("hyperSpec")
will give you the correct reference.

The project homepage is http://hyperspec.r-forge.r-project.org

hyperSpec documentation built on May 2, 2019, 5:45 p.m.