Home > Net >  Is there a way in R to distribute geocoordinates around a starting point?
Is there a way in R to distribute geocoordinates around a starting point?

Time:01-28

Hey Guys for my Bachelor Thesis I'm looking for a method to distribute geocoordinates around a starting point.

I want to generate the address data of 100 employees of a fictitious company.The company location is the starting point. Then I want to distribute the addresses/coordinates around the starting point after static surveys for the distance from the employee to the employer in Germany.

The distributions are for example: under 5km : 26.6% 5-10km: 21.7% 10 - 25km: 29.1%

So I want to distribute 26.6% of the employees in a 5km radius, randomly, around my company location of (49.0,12.1).

and so on...

Is there a method/package for this?

So far I use rgeo, but there, as far as I know, I can distribute coordinates only within a fixed boundary, but not around a starting point.

CodePudding user response:

Assuming cp is company starting point, then something like:

library(sf)
#> Linking to GEOS 3.9.0, GDAL 3.2.2, PROJ 7.2.1; sf_use_s2() is TRUE
cp <- st_sfc(st_point(x = c(362665, 362017)), crs = 2180)
buffer_size <- 5000
buffer <- st_buffer(cp, buffer_size ) 

samples <- st_sample(buffer, 26)

plot(buffer)
plot(cp, add = T, pch = 22)
plot(samples, add=T, pch = 18)

Created on 2022-01-27 by the reprex package (v2.0.1)

  •  Tags:  
  • Related