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!
Related Posts with Generate random points from a given point coordinates
Including squared variables in logistic regression change direction of relationship. Why?Hello everyone, I have a logistic regression with an extensive set of control variables. My depende…
Merging two datasetsHi, I have to merge two datasets for my dissertation project. I am looking at police numbers and cri…
SVYSET Specification for 2-Level HLM ModelHello, Good morning, sorry this is a repost of my previously unanswered question -- I am adding exp…
Changing the colour of individual markers in twoway scatter graphHello Specifically I am using serrbar which I understand has the same options as graph twoway. I ha…
(Propensity Score) Matching with baseline data of the treatment groupHi Stataliste'ers, A more theoretical question here. I am currently working on cleaning my data for…
Subscribe to:
Post Comments (Atom)
0 Response to Generate random points from a given point coordinates
Post a Comment