GO-Ve01
ServicesDevelopersBooksDictionaryPapersWikidataEncyclopediaSearchBabelCareersDeck

Geohash

Geohash is a public domain geocode system invented in 2008 by Gustavo Niemeyer which encodes a geographic location into a short string of letters and digits. Similar ideas were introduced by G.M. Morton in 1966. It is a hierarchical spatial data structure which subdivides space into buckets of grid shape, which is one of the many applications of what is known as a Z-order curve, and generally space-filling curves. Geohashes offer properties like arbitrary precision and the possibility of gradually removing characters from the end of the code to reduce its size (and gradually lose precision). Geohashing guarantees that the longer a shared prefix between two geohashes is, the spatially closer... Source: e01 Encyclopedia. Licence: CC BY-SA 4.0.

Geohash is a public domain geocode system invented in 2008 by Gustavo Niemeyer which encodes a geographic location into a short string of letters and digits. Similar ideas were introduced by G.M. Morton in 1966. It is a hierarchical spatial data structure which subdivides space into buckets of grid shape, which is one of the many applications of what is known as a Z-order curve, and generally space-filling curves. Geohashes offer properties like arbitrary precision and the possibility of gradually removing characters from the end of the code to reduce its size (and gradually lose precision). Geohashing guarantees that the longer a shared prefix between two geohashes is, the spatially closer they are together. The reverse of this is not guaranteed, as two points can be very close but have a short or no shared prefix. For example, using the table above and the constant B=32 , the Geohash ezs42 can be converted to a decimal representation by ordinary positional notation: [ ezs42 ] 32ghs = [(e \times B^4) + (z \times B^3) + (s \times B^2) + (4 \times B^1) + (2 \times B^0)]_{32ghs} = [e]_{32ghs} \times B^4 + [z]_{32ghs} \times B^3 + [s]_{32ghs} \times B^2 + [4]_{32ghs} \times B^1 + [2]_{32ghs} \times B^0 = [13]_{10} \times B^4 + [31]_{10} \times B^3 + [24]_{10} \times B^2 + [4]_{10} \times B^1 + [2]_{10} \times B^0 = 13 \times 1048576 + 31 \times 32768 + 24 \times 1024 + 4 \times 32 + 2 \times 1 = 13631488 + 1015808 + 24576 + 128 + 2 = 14672002 It is possible to build the "И-order curve" from the Z-order curve by merging neighboring cells and indexing the resulting rectangular grid by the function j = \left\lfloor\frac{i}{2}\right\rfloor . The illustration shows how to obtain the grid of 32 rectangular cells from the grid of 64 square cells. The most important property of Geohash for humans is that it preserves spatial hierarchy in the code prefixes. For example, in the "1 Geohash digit grid" illustration of 32 rectangles, above, the spatial region of the code e (rectangle of greyish blue circle at position 4,3) is preserved with prefix e in the "2 digit grid" of 1024 rectangles (scale showing em and greyish green to blue circles at grid). [e]_{32ghs}=[13]_{10}=[01101]_2 [z]_{32ghs}=[31]_{10}=[11111]_2 [s]_{32ghs}=[24]_{10}=[11000]_2 [4]_{32ghs}=[4]_{10}=[00100]_2 [2]_{32ghs}=[2]_{10}=[00010]_2 . This operation results in the bits 01101 11111 11000 00100 00010 . Starting to count from the left side with the digit 0 in the first position, the digits in the even positions form the longitude code ( 0111110000000 ), while the digits in the odd positions form the latitude code ( 101111001001 ). Each binary code is then used in a series of divisions, considering one bit at a time, again from the left to the right side. For the latitude value, the interval −90 to +90 is divided by 2, producing two intervals: −90 to 0, and 0 to +90. Since the first bit is 1, the higher interval is chosen, and becomes the current interval. The procedure is repeated for all bits in the code. Finally, the latitude value is the center of the resulting interval. Longitudes are processed in an equivalent way, keeping in mind that the initial interval is −180 to +180. For example, in the latitude code 101111001001 , the first bit is 1, so we know our latitude is somewhere between 0 and 90. Without any more bits, we'd guess the latitude was 45, giving us an error of ±45. Since more bits are available, we can continue with the next bit, and each subsequent bit halves this error. This table shows the effect of each bit. At each stage, the relevant half of the range is highlighted in green; a low bit selects the lower range, a high bit selects the upper range. The column "mean value" shows the latitude, simply the mean value of the range. Each subsequent bit makes this value more precise. (The numbers in the above table have been rounded to 3 decimal places for clarity) Final rounding should be done carefully in a way that \min \le \mathrm{round}(value) \le \max So while rounding 42.605 to 42.61 or 42.6 is correct, rounding to 43 is not. At 30 Degrees (Mid Latitudes) the error is 110.852/96.486 = 14.89% At 60 Degrees (High Arctic) the error is 111.412/55.800 = 99.67%, reaching infinity at the poles. Note that these limitations are not due to geohashing, and not due to latitude-longitude coordinates, but due to the difficulty of mapping coordinates on a sphere (non linear and with wrapping of values, similar to modulo arithmetic) to two dimensional coordinates and the difficulty of exploring a two dimensional space uniformly. The first is related to Geographical coordinate system and Map projection, and the other to Hilbert curve and z-order curve. Once a coordinate system is found that represents points linearly in distance and wraps up at the edges, and can be explored uniformly, applying geohashing to those coordinates will not suffer from the limitations above. While it is possible to apply geohashing to an area with a Cartesian coordinate system, it would then only apply to the area where the coordinate system applies. Despite those issues, there are possible workarounds, and the algorithm has been successfully used in Elasticsearch, MongoDB, HBase, Redis, and Accumulo to implement proximity searches.

source: e01 Encyclopedia · licence: CC BY-SA 4.0 · page · source revision

Cite this

"Geohash". 1791091520. e01 Encyclopedia. CC BY-SA 4.0. https://en.wikipedia.org/w/index.php?oldid=1378392817

JSON record · API collection · BibTeX · RIS · CSL-JSON · citation policy

Save to pass ·