def elevation2(lat, lon, timeout=2.0): '''Get the geoid elevation at an C{NAD83} to C{NAVD88} location. @arg lat: Latitude (C{degrees}). @arg lon: Longitude (C{degrees}). @kwarg timeout: Optional, query timeout (seconds). @return: An L{Elevation2Tuple}C{(elevation, data_source)} or (C{None, "error"}) in case of errors. @raise ValueError: Invalid B{C{timeout}}. @note: The returned C{elevation} is C{None} if B{C{lat}} or B{C{lon}} is invalid or outside the C{Conterminous US (CONUS)}, if conversion failed or if the query timed out. The C{error} is the C{HTTP-, IO-, SSL-, Type-, URL-} or C{ValueError} as a string (C{str}). @see: U{USGS National Map<https://NationalMap.gov/epqs>}, the U{FAQ<https://www.USGS.gov/faqs/what-are-projection- horizontal-and-vertical-datum-units-and-resolution-3dep-standard-dems>}, U{geoid.py<https://Gist.GitHub.com/pyRobShrk>}, module L{geoids}, classes L{GeoidG2012B}, L{GeoidKarney} and L{GeoidPGM}. ''' try: x = _qURL('https://NED.USGS.gov/epqs/pqs.php', # 'https://NationalMap.gov/epqs/pqs.php' x=Lon(lon).toStr(prec=6), y=Lat(lat).toStr(prec=6), units='Meters', # 'Feet', capitalized output=_XML_.lower(), # _JSON_, lowercase only timeout=Scalar(timeout=timeout)) if x[:6] == '<?xml ': e = _xml('Elevation', x) try: e = float(e) if -1000000 < e < 1000000: return Elevation2Tuple(e, _xml('Data_Source', x)) e = 'non-CONUS %.2F' % (e,) except (TypeError, ValueError): pass else: e = _no_(_XML_, Fmt.QUOTE2(clips(x, limit=128, white=_SPACE_))) except (HTTPError, IOError, TypeError, ValueError) as x: e = repr(x) e = _error(elevation2, lat, lon, e) return Elevation2Tuple(None, e)
def geoidHeight2(lat, lon, model=0, timeout=2.0): '''Get the C{NAVD88} geoid height at an C{NAD83} location. @arg lat: Latitude (C{degrees}). @arg lon: Longitude (C{degrees}). @kwarg model: Optional, geoid model ID (C{int}). @kwarg timeout: Optional, query timeout (seconds). @return: An L{GeoidHeight2Tuple}C{(height, model_name)} or C{(None, "error"}) in case of errors. @raise ValueError: Invalid B{C{timeout}}. @note: The returned C{height} is C{None} if B{C{lat}} or B{C{lon}} is invalid or outside the C{Conterminous US (CONUS)}, if the B{C{model}} was invalid, if conversion failed or if the query timed out. The C{error} is the C{HTTP-, IO-, SSL-, Type-, URL-} or C{ValueError} as a string (C{str}). @see: U{NOAA National Geodetic Survey <https://www.NGS.NOAA.gov/INFO/geodesy.shtml>}, U{Geoid<https://www.NGS.NOAA.gov/web_services/geoid.shtml>}, U{USGS10mElev.py<https://Gist.GitHub.com/pyRobShrk>}, module L{geoids}, classes L{GeoidG2012B}, L{GeoidKarney} and L{GeoidPGM}. ''' try: j = _qURL('https://Geodesy.NOAA.gov/api/geoid/ght', lat=Lat(lat).toStr(prec=6), lon=Lon(lon).toStr(prec=6), model=(model if model else NN), timeout=Scalar(timeout=timeout)) # PYCHOK indent if j[:1] == '{' and j[-1:] == '}' and j.find('"error":') > 0: d, e = _json(j), 'geoidHeight' if isinstance(_xkwds_get(d, error=_n_a_), float): h = d.get(e, None) if h is not None: m = _xkwds_get(d, geoidModel=_n_a_) return GeoidHeight2Tuple(h, m) else: e = _JSON_ e = _no_(e, Fmt.QUOTE2(clips(j, limit=256, white=_SPACE_))) except (HTTPError, IOError, ParseError, TypeError, ValueError) as x: e = repr(x) e = _error(geoidHeight2, lat, lon, e) return GeoidHeight2Tuple(None, e)
import numpy v.append(_name_version(numpy)) except ImportError: pass try: import scipy v.append(_name_version(scipy)) except ImportError: pass x = os_path.basename(pygeodesy_abspath) print('%s%s (%s)' % (x, _COMMASPACE_.join(p), _COMMASPACE_.join(v))) except ImportError: m = os_path.dirname(__file__).replace(os.getcwd(), _DOT_).strip() if len(m.split()) > 1: m = Fmt.QUOTE2(m) v = sys.version_info[0] if v < 3: v = NN print('usage: python%s -m %s' % (v, m)) # **) MIT License # # Copyright (C) 2016-2021 -- mrJean1 at Gmail -- All Rights Reserved. # # Permission is hereby granted, free of charge, to any person obtaining a # copy of this software and associated documentation files (the "Software"), # to deal in the Software without restriction, including without limitation # the rights to use, copy, modify, merge, publish, distribute, sublicense, # and/or sell copies of the Software, and to permit persons to whom the # Software is furnished to do so, subject to the following conditions: