get_distance_to_bounds: Get distance from point to bounds

Description Usage Arguments Examples

View source: R/anem_geoprocessing.R

Description

Get distance from point to bounds. Location on the boundaries has to fall within the segment x1, y1, x2, y2

Usage

1
get_distance_to_bounds(loc, bounds, return_locations = FALSE)

Arguments

loc

Location given as c(x,y) or as data.frame and $x, $y

bounds

Boundary object with m and b or x1, y1, x2, y2

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
## Not run: 
bounds <- define_bounds(bounds_example)
loc <- c(150,150)
get_distance_to_bounds(loc,bounds)

bounds_df <- data.frame(bound_type=c("CH","NF","NF","NF"),m=c(-2,0.5,-2,0.5),b=c(0,0,100,20))
bounds <- define_bounds(bounds_df)
loc <- data.frame(x=c(-200,0,200,50),y=c(-200,0,200,-50))
get_distance_to_bounds(loc,bounds)

library(ggplot2)
ggplot(bounds) +
  geom_segment(data=bounds,aes(x1,y1,xend=x2,yend=y2)) +
  geom_point(data=loc,aes(x,y)) +
  coord_equal()

## End(Not run)

gopalpenny/anem documentation built on Dec. 20, 2020, 5:27 a.m.