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

Class Geohash

object --+        
         |        
basestring --+    
             |    
           str --+
                 |
                Geohash

Geohash class, sub-class of str.

Instance Methods
 
__repr__(self)
repr(x)
 
adjacent(self, direction)
Determines adjacent cell in given compass direction.
 
bounds(self, LatLon)
Returns SW/NE lat-/longitude bounds of this geohash cell.
 
distance1(self, other)
Estimates the distance between this and an other geohash (from the cell sizes).
 
distance2(self, other, radius=6371008.77141)
Approximates the distance between this and an other geohash (with Pythagoras' theorem).
 
distance3(self, other, radius=6371008.77141)
Computes the great-circle distance between this and an other geohash (using the Haversine formula).
 
toLatLon(self, LatLon, **kwds)
Returns (the approximate center of) this geohash cell as an instance of the supplied LatLon class.

Inherited from str: __add__, __contains__, __eq__, __format__, __ge__, __getattribute__, __getitem__, __getnewargs__, __getslice__, __gt__, __hash__, __le__, __len__, __lt__, __mod__, __mul__, __ne__, __rmod__, __rmul__, __sizeof__, __str__, 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 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)
New Geohash.
Properties
  latlon
Gets the lat-/longitude of (the approximate center of) this geohash as 2-Tuple (lat, lon) in degrees.
  neighbors
Gets all 8 adjacent cells as a dict(N=, NE=, E= ..., SW=) of Geohashes.
  sizes
Gets the lat- and longitudinal size of this cell as a 2-tuple (latHeight, lonWidth) in meter.
  N
Gets the cell North of this (Geohash).
  S
Gets the cell South of this (Geohash).
  E
Gets the cell East of this (Geohash).
  W
Gets the cell West of this (Geohash).
  NE
Gets the cell NorthEast of this (Geohash).
  NW
Gets the cell NorthWest of this (Geohash).
  SE
Gets the cell SouthEast of this (Geohash).
  SW
Gets the cell SouthWest of this (Geohash).

Inherited from object: __class__

Method Details

__new__(cls, cll, precision=None)
Static Method

 

New Geohash.

Parameters:
  • cll - Cell or location (Geohash, LatLon or string).
Returns: a new object with type S, a subtype of T
New Geohash.
Overrides: object.__new__

__repr__(self)
(Representation operator)

 

repr(x)

Overrides: object.__repr__
(inherited documentation)

adjacent(self, direction)

 

Determines adjacent cell in given compass direction.

Parameters:
  • direction - Compass direction ('N', 'S', 'E' or 'W').
Returns:
Geohash of adjacent cell (Geohash).
Raises:
  • ValueError - Invalid direction or geohash.

bounds(self, LatLon)

 

Returns SW/NE lat-/longitude bounds of this geohash cell.

Parameters:
  • LatLon - LatLon class to use (LatLon).
Returns:
2-Tuple (LatLonSW, LatLonNE) of LatLons for the lower-left respectively upper-right corner.

distance1(self, other)

 

Estimates 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.

distance2(self, other, radius=6371008.77141)

 

Approximates the distance between this and an other geohash (with Pythagoras' theorem).

Parameters:
  • other - The other geohash (Geohash).
  • radius - Optional earth radius (meter) or None.
Returns:
Approximate distance (meter, same units as radius).
Raises:
  • TypeError - The other is not a Geohash, LatLon or str.

distance3(self, other, radius=6371008.77141)

 

Computes the great-circle distance between this and an other geohash (using the Haversine formula).

Parameters:
  • other - The other geohash (Geohash).
  • radius - Optional earth radius (meter).
Returns:
Great-circle distance (meter, same units as radius).
Raises:
  • TypeError - The other is not a Geohash, LatLon or str.

toLatLon(self, LatLon, **kwds)

 

Returns (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).

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

latlon

Gets the lat-/longitude of (the approximate center of) this geohash as 2-Tuple (lat, lon) in degrees.

Example:

>>> geohash.Geohash('geek').latlon  # 65.478515625, -17.75390625
>>> geohash.decode('geek')  # '65.48', '-17.75'
Get Method:
latlon(self) - Gets the lat-/longitude of (the approximate center of) this geohash as 2-Tuple (lat, lon) in degrees.

neighbors

Gets all 8 adjacent cells as a dict(N=, NE=, E= ..., SW=) of Geohashes.

JSname: neighbours.

Get Method:
neighbors(self) - Gets all 8 adjacent cells as a dict(N=, NE=, E= ..., SW=) of Geohashes.

sizes

Gets the lat- and longitudinal size of this cell as a 2-tuple (latHeight, lonWidth) in meter.

Get Method:
sizes(self) - Gets the lat- and longitudinal size of this cell as a 2-tuple (latHeight, lonWidth) in meter.

N

Gets the cell North of this (Geohash).

Get Method:
N(self) - Gets the cell North of this (Geohash).

S

Gets the cell South of this (Geohash).

Get Method:
S(self) - Gets the cell South of this (Geohash).

E

Gets the cell East of this (Geohash).

Get Method:
E(self) - Gets the cell East of this (Geohash).

W

Gets the cell West of this (Geohash).

Get Method:
W(self) - Gets the cell West of this (Geohash).

NE

Gets the cell NorthEast of this (Geohash).

Get Method:
NE(self) - Gets the cell NorthEast of this (Geohash).

NW

Gets the cell NorthWest of this (Geohash).

Get Method:
NW(self) - Gets the cell NorthWest of this (Geohash).

SE

Gets the cell SouthEast of this (Geohash).

Get Method:
SE(self) - Gets the cell SouthEast of this (Geohash).

SW

Gets the cell SouthWest of this (Geohash).

Get Method:
SW(self) - Gets the cell SouthWest of this (Geohash).