mark_inside_polygon: Mark coordinates within a polygon

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

View source: R/mark_inside_polygon.R

Description

A column will be created that indicates whether a coordinate lies within a polygon or not. See also point.in.polygon.

Usage

1
2
3
mark_inside_polygon(
  tracks, polygon, bind = TRUE, drop = TRUE, cname = "in_polygon"
)

Arguments

tracks

psyo. Data frame with tracks.

polygon

list. A list with the column lon (numeric) and lat (numeric).

bind

logical. Return the distance as list (FALSE) or add it to tracks (TRUE).

drop

logical. If TRUE and only one observation is returned drop the data frame and collapse the return value to a vector.

cname

character. The name of the new column.

Value

psyo

Credit

If you use 'psyosphere' for commercial use or research, please support us by include one off the following references:

Author(s)

Benjamin Ziepert. Please send feedback to: feedback-psyosphere@analyse-gps.com.

See Also

point.in.polygon

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
## Not run: \dontrun{
# Create polygon
lon <- c(4.92, 4.93, 4.93, 4.92, 4.92)
lat <- c(52.311, 52.311, 52.308, 52.308, 52.311)
poly <- data.frame(lon, lat)
remove(lon, lat)

# Get data
data(psyo)

# Plot polygon and data
plot <- plot_tracks(psyo, t_id = "")
plot <- plot_polygon(poly, plot = plot)
plot

# Mark coordinates within plygon
psyo <- mark_inside_polygon(psyo, poly)

# Plot inside polygon in different color
in_poly <- psyo[ psyo[,"in_polygon"] != 0,]
in_poly[,"dot_color"] <- "red"
plot_tracks(in_poly, plot = plot)
}
## End(Not run)

psyosphere documentation built on July 2, 2020, 12:08 a.m.