-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathusgs.py
More file actions
31 lines (20 loc) · 753 Bytes
/
usgs.py
File metadata and controls
31 lines (20 loc) · 753 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
from lxml import etree
import urllib
def getAltitudeUSGS(lat, lon):
print "getAltitudeUSGS(%s, %s)" % (lat, lon)
url = "http://gisdata.usgs.net/xmlwebservices2/elevation_service.asmx/getElevation"
params = {
'X_Value' : lon,
'Y_Value' : lat,
'Elevation_Units' : 'meters',
'Source_Layer' : '',
'Elevation_Only' : ''
}
print "Params: %s" % (str(params))
print "URL: %s?%s" % (url, urllib.urlencode(params))
f = urllib.urlopen(url, urllib.urlencode(params))
doc = etree.fromstring(f.read())
alt = float(doc.find('Elevation_Query').find('Elevation').text)
f.close()
return alt
print getAltitudeUSGS(41.7296877, -87.5578934)