Package pygeodesy :: Module webmercator |
[frames] | no frames]

# Module webmercator

Web Mercator (WM) classes Wm and WebMercatorError and functions parseWM and toWm.

Pure Python implementation of a Web Mercator (aka Pseudo-Mercator) class and conversion functions for spherical and near-spherical earth models.

References Google Maps / Bing Maps Spherical Mercator Projection, Geomatics Guidance Note 7, part 2 and Implementation Practice Web Mercator Map Projection.

Version: 20.01.22

Classes
| WebMercatorError Web Mercator (WM) parse or Wm issue.
| Wm Web Mercator (WM) coordinate.

Functions
parseWM(strWM, radius=6378137.0, Wm=<class 'pygeodesy.webmercator.Wm'>, name=`'````'`) Parse a string representing a WM coordinate, consisting of easting, northing and an optional radius. |
toWm(latlon, lon=None, radius=6378137.0, Wm=<class 'pygeodesy.webmercator.Wm'>, name=`'````'`) Convert a lat-/longitude point to a WM coordinate. |

Variables
| __all__ = `_ALL_LAZY.webmercator`

Function Details

### parseWM(strWM, radius=6378137.0, Wm=<class 'pygeodesy.webmercator.Wm'>, name=`'````'`) |
Parse a string representing a WM coordinate, consisting of easting, northing and an optional radius. Parameters: `strWM` - A WM coordinate (`str`). `radius` - Optional earth radius (`meter`). `Wm` - Optional (sub-)class to return the WM coordinate (Wm) or `None`. `name` - Optional name (`str`). Returns: The WM coordinate (`Wm`) or an EasNorRadius3Tuple`(easting, northing, radius)` if `Wm` is `None`. Raises: `WebMercatorError` - Invalid `strWM`. Example:
    >>> u = parseWM('448251 5411932')
    >>> u.toStr2()  # [E:448251, N:5411932]

### toWm(latlon, lon=None, radius=6378137.0, Wm=<class 'pygeodesy.webmercator.Wm'>, name=`'````'`) |
Convert a lat-/longitude point to a WM coordinate. Parameters: `latlon` - Latitude (`degrees`) or an (ellipsoidal or spherical) geodetic `LatLon` point. `lon` - Optional longitude (`degrees` or `None`). `radius` - Optional earth radius (`meter`). `Wm` - Optional (sub-)class to return the WM coordinate (Wm) or `None`. `name` - Optional name (`str`). Returns: The WM coordinate (`Wm`) or an EasNorRadius3Tuple`(easting, northing, radius)` if `Wm` is `None`. Raises: `ValueError` - If `lon` value is missing, if `latlon` is not scalar, if `latlon` is beyond the valid WM range and rangerrors is set to `True` or if `radius` is invalid. Example:
    >>> p = LatLon(48.8582, 2.2945)  # 448251.8 5411932.7
    >>> w = toWm(p)  # 448252 5411933
    >>> p = LatLon(13.4125, 103.8667)  # 377302.4 1483034.8
    >>> w = toWm(p)  # 377302 1483035