shaper: Code snippets defining ranges based on points located on a...

Description Usage Arguments Value Examples

View source: R/utility.R

Description

The function returns snippets of code that you can paste in your script after you select points on a plot. Useful for defining areas on a map. The default methods assume that you will first click in the bottom left and then in the bottom right corner.

Usage

1
shaper(f = "p", n = 2, round = 2, ...)

Arguments

f

(character) A single letter value specifying for which function's arugment format you want to get parameters. "p" is for plot, "r" is for rect, "s" is for segments. "e" returns a call to create an extent class object from the package raster. "m" will return code to define a 2 column matrix.

n

(integer) The number of points to request.

round

(integer) Number of digits to round to, can be two values, first is for x second for y.

...

arguments passed to the locator function

Value

For certain methods ("m" and "e") the function returns a matrix or extent class object if the function output is assigned to a name.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
# plot something
data(dems)
mapplot(dems[1], col="earth")
# click 5 times to get the long-lat coords of 5 points
# shaper("m",5)
# example output:
mat <- matrix(c(                
  -2.89, 31.55,
  3.32, 26.99,
  21.17, 17.87,
  33.6, 11.03,
  5.65, 19.39
), ncol=2, byrow=TRUE)
#plot them 
points(mat)

chronosphere documentation built on April 19, 2021, 1:07 a.m.