# Math/Random Question

## Recommended Posts

Math/Random Question

How would I randomly get all of the latitude and longitude coordinates within 25 miles of a known latitude and longitude point? I would like to be able to randomly cycle though all of the latitude and longitude coordinates within 25 miles of any point without repeating a coordinate.

Right now I am using GEOSsoftâ€™s distance UDF to get the distance between any to points but I am not sure how to get ALL of latitude and longitude coordinates within a certain distance.

What I am using now:

`\$Distance = _Haversine(\$Lat1, \$Lon1, \$Lat2, \$Lon2)`

##### Share on other sites

The math should be pretty basic, since there are exactly 60 nautical miles per degree of latitude or longitude (69.04 statute miles). So there is no complicated conversion to do, i.e. 25nm/60 = 0.417deg, or 25sm/69.04 = 0.362deg.

Getting ALL coordinates anywhere requires an answer to the resolution you want. A 10nm grid? 1nm grid? 100yd grid? Feet, inches? How big a table do you want to make?

It would be more sensible to arrange things where you can just test a given value to see if it's in range. Trying to create a huge table of all possible values is not efficient for most uses.

It's not as simple for longitude as it is with latitude, as pointed out by Darknvader500a, below.

Edited by PsaltyDS

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

##### Share on other sites

The math should be pretty basic, since there are exactly 60 nautical miles per degree of latitude or longitude (69.04 statute miles). So there is no complicated conversion to do, i.e. 25nm/60 = 0.417deg, or 25sm/69.04 = 0.362deg.

Getting ALL coordinates anywhere requires an answer to the resolution you want. A 10nm grid? 1nm grid? 100yd grid? Feet, inches? How big a table do you want to make?

It would be more sensible to arrange things where you can just test a given value to see if it's in range. Trying to create a huge table of all possible values is not efficient for most uses.

Thank you. I think I have figured out how I am going to do it.

##### Share on other sites

As PSalty said, one degree in latitude = 60nm. However the distance of a degree in Longitude will vary with how high you are above the equator. At the equator, it will be approx 60nm. At the poles, it will be approximately 0.

A quick gooley search found this:

Length of 1 degree of Longitude = cosine (latitude) * length of degree (miles) at equator from

-Hope this helps

## Create an account

Register a new account