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)
Determine the adjacent cell in given compass direction.
 
bounds(self, LatLon)
Return the SW/NE lat-/longitude bounds of this geohash cell.
 
distance1(self, other)
Estimate the distance between this and an other geohash (from the cell sizes).
 
distance2(self, other, radius=6371008.77141)
Approximate the distance between this and an other geohash (with Pythagoras' theorem).
 
distance3(self, other, radius=6371008.77141)
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 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
Get the lat-/longitude of (the approximate center of) this geohash as 2-Tuple (lat, lon) in degrees.
  neighbors
Get all 8 adjacent cells as a dict(N=, NE=, E= ..., SW=) of Geohashes.
  sizes
Get the lat- and longitudinal size of this cell as a 2-tuple (latHeight, lonWidth) in meter.
  N
Get the cell North of this (Geohash).
  S
Get the cell South of this (Geohash).
  E
Get the cell East of this (Geohash).
  W
Get the cell West of this (Geohash).
  NE
Get the cell NorthEast of this (Geohash).
  NW
Get the cell NorthWest of this (Geohash).
  SE
Get the cell SouthEast of this (Geohash).
  SW
Get 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)

 

Determine the 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)

 

Return the 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)

 

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.

distance2(self, other, radius=6371008.77141)

 

Approximate 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)

 

Compute 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)

 

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

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

Get 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) - Get the lat-/longitude of (the approximate center of) this geohash as 2-Tuple (lat, lon) in degrees.

neighbors

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

JSname: neighbours.

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

sizes

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

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

N

Get the cell North of this (Geohash).

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

S

Get the cell South of this (Geohash).

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

E

Get the cell East of this (Geohash).

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

W

Get the cell West of this (Geohash).

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

NE

Get the cell NorthEast of this (Geohash).

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

NW

Get the cell NorthWest of this (Geohash).

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

SE

Get the cell SouthEast of this (Geohash).

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

SW

Get the cell SouthWest of this (Geohash).

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