geo_surround_poly {geosed} | R Documentation |
Geo Polygon
Description
Generates a collection of points that are equidistant to the center coordinates given and are distributed equally around the center
Usage
geo_surround_poly(coordinates, distance, sides)
Arguments
coordinates |
A vector of the center latitude and longitude point |
distance |
Distance to move away from center for each bearing |
sides |
Number of polygon sides |
Value
Returns a matrix of latitude and longitude points.
Author(s)
Shant Sukljian
See Also
Examples
# Load required packages
library(mapview)
library(sp)
# Create sample geo dataset
sample_coord <-
matrix(
c(
sample(327131680:419648450, 1) / 10000000,
sample(-1147301410:-1241938690, 1) / 10000000
),
ncol = 2
)
# Create 80 sided polygon based on a random center and radius
geo_poly <- geo_surround_poly(sample_coord, sample(50:500, 1), 80)
# Join all the points into a single matrix
bound_poly <- rbind(sample_coord, geo_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]