Convert Google maps link to coordinates

て烟熏妆下的殇ゞ 提交于 2019-12-11 09:55:14

问题


How do I convert a Google maps link to GPS coordinates? (I think

10°11'12.0"N 13°14'15.0"E

is an example of a common GPS coordinate format.)

The reason I ask is that Google Maps for Android (I use Samsung Galaxy Note 3) does not seem to give coordinates. It will only give Google links. (Any instructions with right click can not be followed in a phone, only in a computer.)

For example. How do I convert the following link to find the coordinates of the Eiffel Tower:

http://goo.gl/maps/VqEsU

I think there have been earlier standards by Google where the hyperlink arguments contained the coordinates. But the current standard is more cryptic.

Right now I want to do it manually in my Android (Samsung Galaxy Note 3) phone. But maybe the question is of interest for programmatic conversion too.

Edit:

This question is NOT about the conversion between decimal and DMS (degrees, minutes, seconds) formats for coordinates. Many web pages and code-snippets are available for that.


回答1:


You need to unshorten the url link, and the result will be and url with coordinates embedded in it. In your example:

https://www.google.com/maps/place/Eiffel+Tower/@48.8583701,2.2922926,17z/data=!3m1!4b1!4m2!3m1!1s0x0:0x8ddca9ee380ef7e0?hl=en

See this topic on how to unshorten using Python: How can I unshorten a URL?

Then you need to parse it for the coordinates, for example by searching for the @ character. Assume your long url is called longurl. In Python, you can do

import re
temp = re.search('@([0-9]?[0-9]\.[0-9]*),([0-9]?[0-9]\.[0-9]*)', longurl, re.DOTALL)
latitude  = temp.groups()[0]
longitude = temp.groups()[1]

(Then you can further convert it from DD to minutes, seconds, if you need that.)




回答2:


This link shows you how to convert coordinates from a Google Maps link (which is in DD, aka decimal degrees) into GPS coordinates (DMS - degrees, minutes, seconds). The general idea is to take the DD value and split it up into the degrees, minutes, and seconds values for latitude and longitude using the following process:

1) Take the integer value. This becomes the degrees.

2) Take the remaining decimal value and multiply it by 60. The integer portion of this value is the minutes.

3) Lastly, take the remaining decimal value and multiply it by 60 again. This is the seconds value (and is generally rounded off to 2 decimal points).

Example: 48.8583701, 2.2944813

Latitude: degrees = 48

0.8583701 * 60 = 51.502206 => minutes = 51

0.502206 * 60 = 30.13236 => seconds = 30.13

Latitude (DMS): 48º 51' 30.13" N

The link also has some code if you want to do it programmatically.



来源:https://stackoverflow.com/questions/32546135/convert-google-maps-link-to-coordinates

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!