Package pygeodesy :: Module geohash :: Class Geohash |
[frames] | no frames]

# Class Geohash

    object --+
             |
    basestring --+
                 |
               str --+
                     |
        object --+   |
                 |   |
      named._Named --+
                     |
       named._NamedStr --+
                         |
                        Geohash

Geohash class, a _NamedStr.

Instance Methods
adjacent(self, direction) Determine the adjacent cell in given compass direction. |
bounds(self, LatLon=None, **kwds) Return the lower-left SW and upper-right NE bounds of this geohash cell. |
distance1(self, other) DEPRECATED, use method `distance1To`. |
distance1To(self, other) Estimate the distance between this and an other geohash (from the cell sizes). |
distance2(self, other, radius=6371008.77141, adjust=False, wrap=False) DEPRECATED, use method `distance2To`. |
distance2To(self, other, radius=6371008.77141, adjust=False, wrap=False) Compute the distance between this and an other geohash using the Equirectangular Approximation / Projection. |
distance3(self, other, radius=6371008.77141, wrap=False) DEPRECATED, use method `distance3To`. |
distance3To(self, other, radius=6371008.77141, wrap=False) Compute the great-circle distance between this and an other geohash using the Haversine formula. |
toLatLon(self, LatLon, **kwds) Return (the approximate center of) this geohash cell as an instance of the supplied `LatLon` class. |
Inherited from `named._NamedStr`: `__repr__`, `__str__`, `toStr`, `toStr2` Inherited from `str`: `__add__`, `__contains__`, `__eq__`, `__format__`, `__ge__`, `__getattribute__`, `__getitem__`, `__getnewargs__`, `__getslice__`, `__gt__`, `__hash__`, `__le__`, `__len__`, `__lt__`, `__mod__`, `__mul__`, `__ne__`, `__rmod__`, `__rmul__`, `__sizeof__`, `capitalize`, `center`, `count`, `decode`, `encode`, `endswith`, `expandtabs`, `find`, `format`, `index`, `isalnum`, `isalpha`, `isdigit`, `islower`, `isspace`, `istitle`, `isupper`, `join`, `ljust`, `lower`, `lstrip`, `partition`, `replace`, `rfind`, `rindex`, `rjust`, `rpartition`, `rsplit`, `rstrip`, `split`, `splitlines`, `startswith`, `strip`, `swapcase`, `title`, `translate`, `upper`, `zfill` Inherited from `named._Named`: `_dot_`, `attrs`, `classof`, `copy` Inherited from `object`: `__delattr__`, `__init__`, `__reduce__`, `__reduce_ex__`, `__setattr__`, `__subclasshook__`

Static Methods
a new object with type S, a subtype of T |
__new__(cls, cll, precision=None, name=`'````'`) New Geohash from an other Geohash instance or `str` or from a `LatLon` instance or `str`. |

Properties
| ab An immutable property (`Read Only`).
| latlon An immutable property (`Read Only`).
| neighbors An immutable property (`Read Only`).
| precision An immutable property (`Read Only`).
| sizes An immutable property (`Read Only`).
| N An immutable property (`Read Only`).
| S An immutable property (`Read Only`).
| E An immutable property (`Read Only`).
| W An immutable property (`Read Only`).
| NE An immutable property (`Read Only`).
| NW An immutable property (`Read Only`).
| SE An immutable property (`Read Only`).
| SW An immutable property (`Read Only`).
Inherited from `named._Named`: `classname`, `classnaming`, `name`, `named`, `named2` Inherited from `object`: `__class__`

Method Details

### __new__(cls, cll, precision=None, name=`'````'`) Static Method |
New Geohash from an other Geohash instance or `str` or from a `LatLon` instance or `str`. Parameters: `cll` - Cell or location (Geohash or `str`, `LatLon` or `str`). `precision` - Optional, the desired geohash length (`int` 1..12), see function geohash.encode for examples. `name` - Optional name (`str`). Returns: a new object with type S, a subtype of T New Geohash. Raises: `TypeError` - Invalid `cll`. `GeohashError` - INValid or non-alphanumeric `cll`. Overrides: object.__new__

### adjacent(self, direction) |
Determine the adjacent cell in given compass direction. Parameters: `direction` - Compass direction ('N', 'S', 'E' or 'W'). Returns: Geohash of adjacent cell (Geohash). Raises: `GeohashError` - Invalid geohash or `direction`.

### bounds(self, LatLon=None, **kwds) |
Return the lower-left SW and upper-right NE bounds of this geohash cell. Parameters: `LatLon` - Optional (sub-)class to return bounds (`LatLon`) or `None`. `kwds` - Optional keyword arguments for LatLon. Returns: A Bounds2Tuple`(latlonSW, latlonNE)` as `LatLon` or a Bounds4Tuple`(latS, lonW, latN, lonE)` if `LatLon` is `None`.

### distance1To(self, other) |
Estimate the distance between this and an other geohash (from the cell sizes). Parameters: `other` - The other geohash (Geohash). Returns: Approximate distance (`meter`). Raises: `TypeError` - The `other` is not a Geohash, `LatLon` or `str`.

### distance2To(self, other, radius=6371008.77141, adjust=False, wrap=False) |
Compute the distance between this and an other geohash using the Equirectangular Approximation / Projection. Parameters: `other` - The other geohash (Geohash). `radius` - Mean earth radius (`meter`) or `None`. `adjust` - Adjust the wrapped, unrolled longitudinal delta by the cosine of the mean latitude (`bool`). `wrap` - Wrap and unroll longitudes (`bool`). Returns: Approximate distance (`meter`, same units as radius) or distance squared (`degrees` squared) if radius is `None` or 0. Raises: `TypeError` - The other is not a Geohash, `LatLon` or `str`. See Also: Local, flat earth approximation, functions

### distance3To(self, other, radius=6371008.77141, wrap=False) |
Compute the great-circle distance between this and an other geohash using the Haversine formula. Parameters: `other` - The other geohash (Geohash). `radius` - Mean earth radius (`meter`). `wrap` - Wrap and unroll longitudes (`bool`). Returns: Great-circle distance (`meter`, same units as radius). Raises: `TypeError` - The other is not a Geohash, `LatLon` or `str`.

### toLatLon(self, LatLon, **kwds) |
Return (the approximate center of) this geohash cell as an instance of the supplied `LatLon` class. Parameters: `LatLon` - Class to use (`LatLon`). `kwds` - Optional keyword arguments for `LatLon`. Returns: This geohash location (`LatLon`). Raises: `GeohashError` - `LatLon` invalid. Example:
    >>> from sphericalTrigonometry import LatLon
    >>> ll = Geohash('u120fxw').toLatLon(LatLon)
    >>> print(repr(ll))  # LatLon(52°12′17.9″N, 000°07′07.64″E)
    >>> print(ll)  # 52.204971°N, 000.11879°E

Property Details

### ab An immutable property (`Read Only`). Get Method: ab(self) - Get the lat- and longitude of (the approximate center of) this geohash as a 2-tuple (lat, lon) in `radians`. Set Method: immutable(inst, value) - Throws an `AttributeError`, always.

### latlon An immutable property (`Read Only`). Get Method: latlon(self) - Get the lat- and longitude of (the approximate center of) this geohash as a 2-tuple (lat, lon) in `degrees`. Set Method: immutable(inst, value) - Throws an `AttributeError`, always.

### neighbors An immutable property (`Read Only`). Get Method: neighbors(self) - Get all 8 adjacent cells as a Neighbors8Dict`(N, NE, E, SE, S, SW, W, NW)` of Geohashes. Set Method: immutable(inst, value) - Throws an `AttributeError`, always.

### precision An immutable property (`Read Only`). Get Method: precision(self) - Get this geohash's precision (`int`). Set Method: immutable(inst, value) - Throws an `AttributeError`, always.

### sizes An immutable property (`Read Only`). Get Method: sizes(self) - Get the lat- and longitudinal size of this cell as a LatLon2Tuple`(lat, lon)` with the latitudinal height and longitudinal width in (`meter`). Set Method: immutable(inst, value) - Throws an `AttributeError`, always.

### N An immutable property (`Read Only`). Get Method: N(self) - Get the cell North of this (Geohash). Set Method: immutable(inst, value) - Throws an `AttributeError`, always.

### S An immutable property (`Read Only`). Get Method: S(self) - Get the cell South of this (Geohash). Set Method: immutable(inst, value) - Throws an `AttributeError`, always.

### E An immutable property (`Read Only`). Get Method: E(self) - Get the cell East of this (Geohash). Set Method: immutable(inst, value) - Throws an `AttributeError`, always.

### W An immutable property (`Read Only`). Get Method: W(self) - Get the cell West of this (Geohash). Set Method: immutable(inst, value) - Throws an `AttributeError`, always.

### NE An immutable property (`Read Only`). Get Method: NE(self) - Get the cell NorthEast of this (Geohash). Set Method: immutable(inst, value) - Throws an `AttributeError`, always.

### NW An immutable property (`Read Only`). Get Method: NW(self) - Get the cell NorthWest of this (Geohash). Set Method: immutable(inst, value) - Throws an `AttributeError`, always.

### SE An immutable property (`Read Only`). Get Method: SE(self) - Get the cell SouthEast of this (Geohash). Set Method: immutable(inst, value) - Throws an `AttributeError`, always.

### SW An immutable property (`Read Only`). Get Method: SW(self) - Get the cell SouthWest of this (Geohash). Set Method: immutable(inst, value) - Throws an `AttributeError`, always.