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
calculate standard errors for predicted rates (uncertainty)Dear STATALIST, I want to calculate the uncertainty of a model and need to calculate standard error…
Orindal outcomes for propensity score matchingFor psmatch2, is it possible for the outcome variable to be an ordinal outcome? For example, in onco…
Post-estimation, predicting the dependent variable with a change to one or more independent variablesDear Stata community, I'm attempting to predict the value of a dependent variable if one of the ind…
Creating a square matrix using two relational variablesHi, I've spent 5-6 hours browsing the help files and past posts, but could not find the answer to w…
First Differences regression and estimateDear members, I am a student new to STATA and may need your help on the below question. I have the…
Subscribe to:
Post Comments (Atom)
0 Response to Generate random points from a given point coordinates
Post a Comment