-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdist_btw_clicks.Rd
35 lines (32 loc) · 1.59 KB
/
dist_btw_clicks.Rd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/dists.R
\name{dist_btw_clicks}
\alias{dist_btw_clicks}
\title{Calculate the distance between sequential mouse clicks on a map}
\usage{
dist_btw_clicks(
calc_distance = raster::pointDistance,
...,
add_paths = list(length = 0.025)
)
}
\arguments{
\item{calc_distance}{A function that calculates distances between two sets of points, such as \code{\link[raster]{pointDistance}}. The first two arguments of this function must accept a dataframe comprising the x and y coordinates of the first and second set of points respectively. The function must return a numeric vector of distances between these.}
\item{...}{Additional arguments passed to \code{calc_distance}, such as \code{lonlat} for \code{\link[raster]{pointDistance}}.}
\item{add_paths}{(optional) A named list of arguments, passed to \code{\link[prettyGraphics]{add_sp_path}}, to customise the paths added to the plot. \code{add_paths = NULL} suppresses this option.}
}
\value{
The function returns a dataframe with an integer ID for each path segment (`segment'), the first and second x and y coordinates (`x', `x2', `y', `y2`) and the distances between these points (`dist'). If \code{add_paths} is not \code{NULL}, the segments are drawn on the map.
}
\description{
This function calculates the distance between sequential mouse clicks on a plotted map, by combining \code{\link[graphics]{locator}} with a distance calculator, such as \code{\link[raster]{pointDistance}}.
}
\examples{
\dontrun{
raster::plot(dat_gebco)
dist_btw_clicks(lonlat = FALSE)
}
}
\author{
Edward Lavender
}