[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: spatial analysis - DISTANCE

From   David Torres <>
Subject   st: spatial analysis - DISTANCE
Date   Sat, 29 Aug 2009 16:26:17 -0400

I am trying to calculate multiple distances from one set of xy coordinates to another using vincenty. In addition to getting those distances, however, I need to somehow list
the ids for the xy coordinates used to calculate the distance.

Here is the piece of code I'm working with:

code excerpt:

g long rad10=.
g double dist1=.
g id1=""
merge using univpoints00_0

forv i=1/`np' {
qui vincenty `=latitude[`i']' `=longitude[`i']' sch_lat sch_lon, hav(dis)
g within10=dis<10
su within10, meanonly
qui replace rad10=r(sum) in `i'
su dis, meanonly
qui replace dist1=r(min) in `i'
qui levelsof unitid if dis==dist1[`i'], loc(vs)
foreach v of loc vs {
 qui replace id1="`v' "+id1 in `i'
drop dis within10

end excerpt

As you can see, I'm getting a count of all sch_lat and sch_lon coordinates within a 10 mile radius of the other set of latitude and longitude points. Then I return only the minimum distance. Will vincenty allow for returning more than just the min, max, mean, or whatever? Or is globdist a better choice for returning multiple distances and the ids
attached to the point the distance to which is being calculated?


David Torres

*   For searches and help try:

© Copyright 1996–2017 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index