Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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

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%

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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.

>Solution :

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)

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading