09 Mar 2018
When working with GPS, it is sometimes helpful to calculate distances between points. But simple Euclidean distance doesn’t cut it since we have to deal with a sphere, or an oblate spheroid to be exact. So we have to take a look at geodesic distances.
One degree of latitude = 110.57 km or 68.71 mi One minute of latitude = 1.84 km or 1.15 mi One second of latitude = 30.72 m or 100.77 ft One degree of longitude = 111.32 km or 69.17 mi One minute of longitude = 1.86 km or 1.15 mi One second of longitude = 30.92 m or 101.45 ft.
There are various ways to handle this calculation problem. For example there is the Great-circle distance, which is the shortest distance between two points on the surface of a sphere. Another similar way to measure distances is by using the Haversine formula, which takes the equation
begin{equation} a = hav(Deltavarphi) + cos(varphi_1) cdot cos(varphi_2) cdot hav(Deltalambda)end{equation}
- This script will calculate the length of one degree of both latitude and longitude, for a specific latitude. Lengths for both are calculated in nautical miles, statute miles, feet, and meters. Enter the specific latitude. Click on Calculate. This is applicable for both a marine or aviation application, and the default is for 'mid-latitude'.
- There are 60 seconds to a minute, so 1 second of latitude is 1/60 mile or 5280/60 feet. That comes to about 90 feet. The distance corresponding to a second of longitude will depend on where you are. If you are at the equator, a circle of longitude is still the same 24,000 miles, so 1 second is again about 90 feet.
- Jan 25, 2020 A degree of longitude is widest at the equator with a distance of 69.172 miles (111.321 kilometers). The distance gradually shrinks to zero as they meet at the poles. At 40 degrees north or south, the distance between a degree of longitude is 53 miles (85 kilometers).
with haversine function
begin{equation} hav(theta) = sin^{2}(frac{theta}{2})end{equation}
and takes this to calculate the geodesic distance
begin{equation} text{distance} = 2 cdot R cdot arctan(sqrt{a}, sqrt{1-a})end{equation}
where the latitude is (varphi), the longitude is denoted as (lambda) and (R) corresponds to Earths mean radius in kilometers (6371
). We can take this formula now and translate it into Python
Important to note is that we have to take the radians of the longitude and latitude values. We can take this function now and apply distances to different cities. Lets say we want to calculate the distances from London to some other cities.
This already gives us some seemingly accurate result, but let’s compare it to another method.
You can also use geopy to measure distances. This package has many different methods for calculating distances, but it uses the Vincenty’s formulae as default, which is a more exact way to calculate distances on earth since it takes into account that the earth is, as previously mentioned, an oblate spheroid. The Vincenty’s formulae is well described in this article.
As you can see, there is a difference between the values, especially since we work with very large distances, which enhances the distortion of our spheroid-shaped Earth.
There is also the pyproj Python package, which offers Python interfaces to PROJ.4. It is a great package to work with map projections, but in there you have also the Geod class which offers various geodesic computations. To calculate the distance between two points we use the inv function, which calculates an inverse transformation and returns forward and back azimuths and distance.
Pdf encrypt 3 0 0. On a geographic sidenote, the forward azimuth is the direction which is defined as a horizontal angle measured clockwise from a north base line and a back azimuth is the opposite direction of the forward azimuth. You could use this information for example to sail the ocean if this is what you intend.
Image from New Old StockPlease enable JavaScript to view the comments powered by Disqus. Related Posts Converting Address to Latitude/Longitude in OneStepFrequently Asked Questions
Stephen P. Morse, San Francisco
Download excel for macbook pro. 1. Why do you show the latitude and longitude several times?
I fetch the values from several different websites for comparisonpurposes(see question 4).
2. Why do the different sets of values sometimes differsignificantly?
That's because of the way the different websites behave when theydon'trecognize the address. Some try to find the closest match for thestreet that you specified. Others give the coordinates of acentralpoint in the specified city, or perhaps a central point in thespecifiedzipcode. The address given below each website's results shows theactual address that the website decided to use.
3. Why is there sometimes no results from specific websites?
Sometimes one or more of the websites happen to be down at the timethe request is made. In that case, resubmitting the same requestmight get a result from a website that didn't show a resultpreviously. And some websites, when they don't recognize an address and are unableto uniquely determine a close match, don't return any results. Andsome websites are for US addresses only.
4. Which website gives the most reliable coordinate values?
Here are some of the pros and cons of each site:
If travelgis does not recognize an address, it will usesomecentral location and not tell you it is doing soThis is a strong disadvantage for travelgis
maporama will sometimes give you a totally bogus result in itsattemptto recognize the address you gave it (see question 4).
That's a strong disadvantage of maporama.
maporama returns the least precise result (less digits after thedecimalpoint)
This is a slight disadvantage for maporama
terraserver and geocoder are for US address only.
[Second thoughts: Above was written when the only sites I queried weretravelgis, maporama, and terraserver. I have since added manymoresites to the list, and I no longer query travelgis. I have notattemptedto do a comparative analysis of all the new sites. I was at onetimequerying gpsvisualizer until I realized that they were getting theirdatafrom maporama. Same is true for google when I realized that theywere getting their data from the same underlying service as yahoo.][Third thoughts: Google and yahoo are no longer getting their datafromthe same underlying server. Either it was true at one time and not anylonger. Or it was never true and I had a faulty test and thought I wasgetting identical results.]
5. How many feet does one second of latitude or longituderepresent?
The earth is approximately 24,000 miles in circumference, whichmeansit is 12,000 miles from the North Pole to the South Pole. And thedifference in latitude from the North Pole (+90 degrees) to the SouthPole(-90 degrees) is 180 degrees. So 1 degree of latitude is12,000/180miles which is 67 miles. Let's round that to 60 miles to make thenext computation simpler. There are 60 minutes to a degree, so 1minute of latitude is 1 mile. There are 60 seconds to a minute,so1 second of latitude is 1/60 mile or 5280/60 feet. That comes toabout 90 feet.
The distance corresponding to a second of longitude will depend onwhereyou are. If you are at the equator, a circle of longitude isstillthe same 24,000 miles, so 1 second is again about 90 feet. If youare at one of the poles, the circle of longitude reduces to a point, so1 second is 0 feet.
OK, we did some approximating in the preceding paragraphs. Toget a more exact value, we should have used 24,860 miles as the earth'scircumference (measured through the poles)and not done any rounding. That would have given us 101 insteadof90 feet to a second of latitude, and 6076 feet to a minute oflatitude. The circumference measured at the equator is 24,901miles, so a minute of longitude at the equator is slightly larger thana minute of latitude -- specifically it is 6086 feet.
(Note that a nautical mile is defined as the distance covered by oneminute of latitude. With the approximate computations done in thefirst paragraph above, we see that one nautical mile is close to onemile. But under the more exact computations, we see that one nautical mile is6076 feet instead of 5280 feet.)
6. What format should the address be in for the batch converter?
Pretty much anything that makes sense. All of the followingformatswill be acceptable:
street address, city, state or province, zipcode
street address, city, state or province
city, state or province, zipcode
city, state or province
street, zipcode
zipcode
7. What does the precision indicate in the batch-mode results?
If the converter was able to find your specific address, thecoordinatesreturned will be for that address. Otherwise if the zipcode wasspecified,it will return the coordinates of some central point in thezipcode. Failing that, it will return the coordinates of some central point inthespecified city or state. The 'precision' indicates whether thecoordinatescorrespond to the 'address', the 'zipcode', the 'city', or the'state'. If the location is completely unrecognizable, the converter willrespondwith 'unable to parse location'.
1 Second Milliseconds[Second thoughts: yahoo no longer returns the precision so I am nolongerable to display it.]
8. Why don't you have a reverse batch geocoder?
[Ignore this question -- I now have a reverse batch geocoder. Original answer is being left here, just for reference.]
First, let me define some terms so everyone knows what we aretalkingabout. Forward geocoding is obtaining the latitude and longitudeof an address. Reverse geocoding is just the opposite --obtainingthe address corresponding to a specified latitude and longitude. Interactive mode is doing geocoding or reverse geocoding one item at atime, and batch mode is doing it for a list of items.
My main latitude/longitude page does both forward and reversegeocodingfor a single address or a single latitude/longitude pair. So itisoperating in interactive mode. There is a batch-mode button onthetop of the page, and that brings up a batch-mode forward geocoder.
Now let me explain why I don't have a batch reverse geocoder. The answer is a bit technical, so bear with me.
My website does not have the geocoding information but rather makesrequests to several underlying websites, such as google. Therequestsgo out from my server to google's server, and google sees my server'sIPaddress on each request. That is not too bad because myinteractiveusers can do only one request at a time. Furthermore, if any oneuser makes too many requests to my website, my code will detect thatandblock him. These two factors together keep the total number ofrequestsfrom my site to google limited to a reasonable amount.
Now batch mode is a different story. People who are doingbatchrequests usually want it because they have thousands of requests tomake. If they go through a batch-mode tool on my site, all those thousandrequestswould go to google with my server's IP address. If several people are doing this (which occurs frequently), the number of requestsfrom my server will become excessive, and they might block my server'sIP address. Then everyone using my website would lose.
How then am I able to offer a forward geocoder in batch mode? That's because one of the forward-geocoding websites allows forrequeststo be made directly from the user's browser and doesn't need anyinterventionfrom code on my server. So I can have the request sent directlyfromthe user's browser and it gets seen by the website as coming from theuser'sIP address. If any one user makes an excessive number ofrequests,it is his IP address that gets blocked and not my server's IP address.
Now reverse geocoding is a different story. There is no wayyoucan interact with any of the reverse-geocoding sites in such a way thatthe request can be handled entirely from the user's browser. Thatmeans I have to have code on my server that makes the actual requestand,as explained above, that could lead to the underlying website blockingmy server's IP address.
[Second thoughts: google now allows for reverse geocoding in such away that the reqauest can be handled entirely from the user'sbrowser. Consequently, I am now able to offer batch reverse geocoding.]
9. Is there a limit to the number of entries in the batchgeocoders?
In theory the answer is no. However in practice, the moreentriesyou have the longer it will take to see the results, and your browsermighttime out. So I suggest you experiment. Start with a smallnumberand see how long it takes. Keep increasing that number until youget to a value that returns results in the maximum time you are willingto wait.
-- Steve Morse