geo_midpoint {geosed}R Documentation

Point of Equidistance to Up to Three Longitude, Latitude Points

Description

Generates a latitude and longitude point that is equidistant to up to three latitude and longitude points

Usage

geo_midpoint(coordinate_matrix, alternative = FALSE)

Arguments

coordinate_matrix

A matrix of latitude and longitude columns and up to three rows

alternative

Whether to use alternative line creation method. Could be needed when nearly inverse angles cause intersections to be ambiguous.

Value

Returns a vector of length 2 containing a latitude and longitude point.

Author(s)

Shant Sukljian

See Also

geo_sed geo_point_dist

Examples


# 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
    )

# Generate circumcenter and radius
gmp <- geo_midpoint(sample_coord)

# Find distance to circumcenter
radius <- geo_point_dist(rbind(sample_coord[1, ], gmp))

# Create 80 sided polygon based on gmp's center and radius
gmp_poly <- geo_surround_poly(gmp, radius, 80)

# Join all the points into a single matrix
bound_poly <- rbind(sample_coord, as.vector(gmp), gmp_poly)

# Create SpacialPoints object and pass to mapview for visualization
mapview(
    SpatialPoints(
        bound_poly[,c(2, 1)],
        proj4string = CRS("+proj=longlat +datum=WGS84")
    )
)



[Package geosed version 0.1.1 Index]