stems.gis.geohash module

Tools for encoding and decoding geohashes

Geohashes are a way of encoding latitude and longitude information into a single value (hash as a str or uint64) by dividing up the world into hierarchical quadrants for a given level of precision. The higher the precision, the more tiers of quadrants are created. When using just one level of precision, for example, divides the globe into 36 zones (a-z, 0-9). By adding letters to the hash, the quandrants get increasingly small to the point where they are useful as global, unique identifiers for pixel coordinates (assuming you pick a precision that creates quadrant cells smaller than your image pixel size).

References

R9457147864ca-1

https://en.wikipedia.org/wiki/Geohash

R9457147864ca-2

https://www.movable-type.co.uk/scripts/geohash.html

stems.gis.geohash.geohash_decode(geohashes, crs=None)[source]

Encode Y/X coordinates into a geohash, reprojecting as needed

Parameters
  • np.ndarry – The geohashes for all Y/X

  • crs (rasterio.crs.CRS, optional) – Reproject Y/X latitude/longitude values for each geohash into this CRS before returning (to help with end-to-end encode/decode)

Returns

  • y (np.ndarray) – Y coordinates

  • x (np.ndarray) – X coordinates

stems.gis.geohash.geohash_encode(y, x, crs=None, precision=12)[source]

Encode Y/X coordinates into a geohash, reprojecting as needed

Parameters
  • y (np.ndarray) – Y coordinates

  • x (np.ndarray) – X coordinates

  • crs (rasterio.crs.CRS, optional) – If Y/X aren’t in latitude/longitude (EPSG:4326), then provide their coordinate reference system

  • precision (int, optional) – Characters of precision for the geohash

Returns

The geohashes for all Y/X (dtype=``np.dtype((‘U’, precision))``)

Return type

np.ndarry