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

# Module webmercator

Web Mercator (WM) projection.

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: 21.07.31

Classes
| EasNorRadius3Tuple 3-Tuple `(easting, northing, radius)`, all in `meter`.
| WebMercatorError Web Mercator (WM) parser or Wm issue.
| Wm Web Mercator (WM) coordinate.

Functions
parseWM(strWM, radius=6378137.0, Wm=<class 'pygeodesy.webmercator.Wm'>, name='') Parse a string `"e n [r]"` 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='', **Wm_kwds) 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 `"e n [r]"` representing a WM coordinate, consisting of easting, northing and an optional radius. Arguments: `strWM` - A WM coordinate (`str`). `radius` - Optional earth radius (`meter`). `Wm` - Optional 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.toRepr()  # [E:448251, N:5411932]

### toWm (latlon, lon=None, radius=6378137.0, Wm=<class 'pygeodesy.webmercator.Wm'>, name='', **Wm_kwds) |
Convert a lat-/longitude point to a WM coordinate. Arguments: `latlon` - Latitude (`degrees`) or an (ellipsoidal or spherical) geodetic `LatLon` point. `lon` - Optional longitude (`degrees` or `None`). `radius` - Optional earth radius (`meter`). `Wm` - Optional class to return the WM coordinate (Wm) or `None`. `name` - Optional name (`str`). `Wm_kwds` - Optional, additional `Wm` keyword arguments, ignored if `Wm is None`. 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