is_inside_plg: Check if a Point is Inside a Polygon

View source: R/i.R

is_inside_plgR Documentation

Check if a Point is Inside a Polygon

Description

This function determines whether a given point lies inside a polygon defined by its vertices.

Usage

is_inside_plg(point, polygon_df, strictly = TRUE)

Arguments

point

A numeric vector with two elements representing the x (first value) and y (second value) coordinates of the point.

polygon_df

A data frame with columns 'x' and 'y', containing the vertices of the polygon.

strictly

Logical, indicating whether the point must strictly lie inside the polygon (TRUE) or might be part of the polygon boundary (FALSE).

Value

Logical value indicating whether the point is inside the polygon.

See Also

sp::point.in.polygon()

Examples

point <- c(2, 3)
polygon_df <- data.frame(x = c(1, 3, 3, 1), y = c(1, 1, 4, 4))
is_inside_plg(point, polygon_df) # Returns TRUE


theMILOlab/SPATA2 documentation built on Feb. 8, 2025, 11:41 p.m.