Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

shaper

Code snippets defining ranges based on points located on a plot


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

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

# 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

Earth System History Variables

v0.4.1
CC BY 4.0
Authors
Adam T. Kocsis, Nussaibah B. Raja
Initial release
2021-04-16

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.