Skip to content

Instantly share code, notes, and snippets.

@pyRobShrk
Last active July 1, 2019 21:27
Show Gist options
  • Save pyRobShrk/8df3a3c422fb1c88882a5e41b284349f to your computer and use it in GitHub Desktop.
Save pyRobShrk/8df3a3c422fb1c88882a5e41b284349f to your computer and use it in GitHub Desktop.
Python function to query USGS 10 meter 3DEP elevation for a given point (lat, long)
from http import client
def USGS10mElev(lat,lon):
usgs = client.HTTPConnection('nationalmap.gov')
usgs.request('GET','/epqs/pqs.php?x=%.6f&y=%.6f&units=FEET&output=xml'% (lon, lat))
result = usgs.getresponse()
if result.status == 200:
xml = result.read()
return float(xml[xml.find(b'<Elevation>')+11:xml.find(b'</Elevation>')-1])
else: return request
@pyRobShrk
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment