# Getting a “square” of lat/lon for database query [duplicate]

So I want to get the square formed by a single point of lat/lons, my plan was to take that point's latitude, divide by 360, and multiply by the circumference of earth. Giving us the distance from the equator.

Now I will take 1/4 the circumference of earth, and subtract by the distance from the equator, giving us the height of triangle T. I can the find the base because I know the initial height, truncated height, and the original base.

Now using the base and height I can use trig to find the minimum and maximum longitude, and the latitude is easy because lets are evenly spaced. Does this sound right?

EDIT:

Let me simplify this question.

How can I find the distance between two points of longitude, at a single point of latitude?

-

## marked as duplicate by whuber♦Apr 8 '13 at 17:25

The range of latitude values is not from 0->360. – nagytech Apr 8 '13 at 0:48
I think you need to work with Projected coordinate system and not geographic lat/lng since you cannot perfrom measurements with lat/lng. – artwork21 Apr 8 '13 at 1:03
Not sure what you are asking for exactly but maybe a look at Great-circle distance, the Haversine formula, and Vincenty's formulae will get you closer. – blah238 Apr 8 '13 at 1:25
Ya, Great Circlt Distance did it, thank you! – OneChillDude Apr 8 '13 at 1:50
Can you turn this into a comprehensive answer to the original question, paste it in below ("Your Answer") and click the tick (check) icon to make it "the answer"? Thanks – BradHards Apr 8 '13 at 3:10

So for me the answer was, because I dont need that much accuracy, to use the Great-circle distance formula.

distance of one degree of longitude = Cos( longitude ) * radius * ( π / 180 ).

Distance of latitude = about 69 miles / degree

-
This formula is correct for distance along a circle (it appears in many places on this site) but it is not the great-circle formula: a circle of latitude is a great circle only at the Equator. To see how incorrect it can be, consider the distance from, say, Mexico City (19.25, -99) and Bombay (19.25, +73) (which aren't too far from the Equator as it is). Your formula gives Cos(19.25)*(73+99)*69 = 11,200 miles, whereas the correct distance is 9730 miles. That 13% error is large. – whuber Apr 8 '13 at 17:22

Are you familiar with python? If you are there's another post which covers your Question!

What tools in Python are available for doing great circle distance + line creation?

-