Hi,

I have a database of coordinates (lat, lon) and I would like to randomly generate a set of new coordinates on a circle around the initial coordinates (and not within a circle). For each point (lat,lon) I want to generate 20 points (lat1;lon1), ... (lat20;lon20), etc. I have already succeeded in generating coordinates within a circle around the centroids, but those are at a distance that varies. I would like all the new coordinates to be at a given distance from the initial point.

Here is the code I use :

use coordinates.dta

forvalues i = 1/20 {
local phi = 2*runiform()*_pi
local r = 0.1
gen lon`i' = `r'* cos(`phi') + lon
gen lat`i' = `r'* sin(`phi') + lat
}

Any help or tips would be much appreciated!