We need to triangulate the three holy lands, and at the centre we will find the answers to the universe
library(sf)
library(geosphere)
library(leaflet)
library(leaflet.extras)
point1 <- c(-122.0173491,47.4995151)
point2 <- c(-83.1249227,39.1548334)
point3 <- c(-0.1610379,51.7470038)
Calculate the geodesic midpoint between each pair of points
midpoints <- midPoint(
rbind(point2, point1, point1),
rbind(point3, point3, point2)
)
Draw lines between point3 and its opposite midpoint, and point1 and its opposite midpoint, and see where they intersect (there are two points, one on each side of the globe)
intersect <- gcIntersect(
point1, midpoints[1,],
point2, midpoints[2,]
)
intersect
## lon1 lat1 lon2 lat2
## [1,] 104.7429 -57.18102 -75.25709 57.18102
wgs84 <- "+proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0"
Create a polygon around the three places
poly <- st_geometry(
st_polygon(list(rbind(point1, point2, point3, point1))),
crs = wgs84
)
Create median lines
medians <- st_geometry(
st_multilinestring(list(
rbind(point1, midpoints[1,]),
rbind(point2, midpoints[2,]),
rbind(point3, midpoints[3,])
)),
crs = wgs84
)
Create a map
leaflet(width = "100%") %>%
# Draw map tiles
addTiles() %>%
# Draw lines between the three places
addGeodesicPolylines(data = poly, steps = 100, smoothFactor = 0.1) %>%
# Draw the median lines in red
addGeodesicPolylines(data = medians, steps = 100, smoothFactor = 0.1, color = "red") %>%
# Add marker for the intersection point
addMarkers(lng = intersect[,"lon2"], lat = intersect[,"lat2"])