# NOT RUN {
# Load required packages
require(mapview)
require(sp)
# Create sample geo dataset
sample_coord <-
matrix(
c(
sample(327131680:419648450, 3) / 10000000,
sample(-1147301410:-1241938690, 3) / 10000000
),
ncol = 2
)
# Calculate distances
(gpd <- geo_point_dist(sample_coord))
# Calculate distances and preserve relationship (Useful for three input points)
(gpd <- geo_point_dist(sample_coord, matrix = TRUE))
# Create SpacialPoints object and pass to mapview for visualization
mapview(
SpatialPoints(
sample_coord[,c(2, 1)],
proj4string = CRS("+proj=longlat +datum=WGS84")
)
)
# }
Run the code above in your browser using DataLab