Compute an approximate angle that correspond to a given distance in both longitude and latitude.

dist2arc(x, dm)

Arguments

x

A sfc_POINT object in longlat coordinates, indicating a position in the globe.

dm

A target distance in m.

Value

A numeric value of angle in decimal degrees, such that a displacement in longitude and latitude by that magnitude corresponds to approximately the given distance.

Details

The distance corresponding to an angle in longitude and latitude depends on the location in the earth and is typically different for both directions.

This function computes the angle that yields approximately the target distance when added to the longitude or the latitude by minimising the squared errors.

The average error is returned as an attribute.

Examples

require(sf) ## What angle yields 1 km at the equator? (and with which precision?) x0 <- st_sfc(st_point(c(0, 0)), crs = 4326) dist2arc(x0, 1e3)
#> [1] 0.009013222 #> attr(,"average_error") #> [1] 3.358412
## Note that this is independent of the longitude x1 <- st_sfc(st_point(c(90, 0)), crs = 4326) dist2arc(x1, 1e3)
#> [1] 0.009013222 #> attr(,"average_error") #> [1] 3.358412
## But is strongly dependent of the latitude x2 <- st_sfc(st_point(c(0, 45)), crs = 4326) x3 <- st_sfc(st_point(c(0, 75)), crs = 4326) dist2arc(x2, 1e3)
#> [1] 0.01023237 #> attr(,"average_error") #> [1] 167.5383
dist2arc(x3, 1e3)
#> [1] 0.01057086 #> attr(,"average_error") #> [1] 507.2814