gvsig-scripting / org.gvsig.scripting / trunk / org.gvsig.scripting / org.gvsig.scripting.app / org.gvsig.scripting.app.mainplugin / src / main / resources-plugin / scripting / scripts / examples / geopy / geopy_01.py @ 564
History | View | Annotate | Download (1.06 KB)
1 |
|
---|---|
2 |
from gvsig import * |
3 |
import geopy |
4 |
|
5 |
def main(*args): |
6 |
#Info
|
7 |
#http://geopy.readthedocs.org/en/latest/#module-geopy.geocoders
|
8 |
|
9 |
print "\n\n Test 01: Geocode" |
10 |
from geopy.geocoders import Nominatim |
11 |
geolocator = Nominatim() |
12 |
location = geolocator.geocode("175 5th Avenue NYC")
|
13 |
print(location.address) |
14 |
print((location.latitude, location.longitude)) |
15 |
print(location.raw) |
16 |
|
17 |
print "\n\n Test 02: Reverse geocode" |
18 |
from geopy.geocoders import Nominatim |
19 |
geolocator = Nominatim() |
20 |
location = geolocator.reverse("52.509669, 13.376294")
|
21 |
print(location.address) |
22 |
print((location.latitude, location.longitude)) |
23 |
print(location.raw) |
24 |
|
25 |
print "\n\n Test 03: Mesouring distance" |
26 |
from geopy.distance import vincenty |
27 |
newport_ri = (41.49008, -71.312796) |
28 |
cleveland_oh = (41.499498, -81.695391) |
29 |
print(vincenty(newport_ri, cleveland_oh).miles) |
30 |
|
31 |
from geopy.distance import great_circle |
32 |
newport_ri = (41.49008, -71.312796) |
33 |
cleveland_oh = (41.499498, -81.695391) |
34 |
print(great_circle(newport_ri, cleveland_oh).miles) |
35 |
|
36 |
pass
|