For one row of an sf data frame, calculate the distance to the closest focal point. Return the name of the focal point, and the angle between focal point and centroid.

closest_focal_point(centroid, focal_points)

Arguments

centroid

a data frame describing one centroid

focal_points

a data frame of the longitude and latitude values

Value

data frame containing the name and location of the closest focal

Examples

# Create a set of polygon centroids
centroids <- create_centroids(tas_sa2, "sa2_5dig_2016")

# Find the closest capital city for the first centroid
closest_focal_point(centroids[1, ], capital_cities)
#> # A tibble: 1 × 5
#>   points focal_longitude focal_latitude focal_distance angle
#>   <chr>            <dbl>          <dbl>          <dbl> <dbl>
#> 1 Hobart            147.          -42.9         16750. -35.6