{"id":4027,"date":"2025-10-15T16:16:46","date_gmt":"2025-10-15T23:16:46","guid":{"rendered":"https:\/\/www.geoplugin.com\/resources\/?p=4027"},"modified":"2026-01-13T13:34:22","modified_gmt":"2026-01-13T21:34:22","slug":"what-is-geohashing-everything-you-need-to-know","status":"publish","type":"post","link":"https:\/\/www.geoplugin.com\/resources\/what-is-geohashing-everything-you-need-to-know\/","title":{"rendered":"What Is Geohashing? Everything You Need To Know"},"content":{"rendered":"\n<p>Have you ever wondered how your ride-sharing app finds riders only nearby instead of the entire city? How does this happen at an algorithmic level?<\/p>\n\n\n\n<p>You might think the system simply compares your (the user&#8217;s) geographical coordinates with those of drivers. But this approach requires scanning the coordinates of all drivers in the database to then find the ones around you.<\/p>\n\n\n\n<p>And scanning each of those coordinates is a two-dimensional search because geographical coordinates consist of latitudes\/longitude pairs.<\/p>\n\n\n\n<p>So the database has to check both axes separately, which further slows down the operation. Why? Because most databases can only handle 1-dimensional data. Pretty complex and time-consuming, I know.<\/p>\n\n\n\n<p>That\u2019s the problem Gustavo Niemeyer noticed back in 2008 and presented the geohashing algorithm.<\/p>\n\n\n\n<p>Geohashing takes a 2D pair of coordinates and turns them into a short alphanumeric string called a geohash. Since this string is linear, databases have to query less data to find nearby points of a given point.<\/p>\n\n\n\n<p>This isn\u2019t the only benefit of geohashing. It offers a lot more, but not without introducing a few inefficiencies along the way.<\/p>\n\n\n\n<p>Read this comprehensive guide on geohashing to explore the good and the bad about geohashing. But more especially, read this blog to learn how the algorithm works. I have explained and demonstrated the steps to give you a thorough understanding.<\/p>\n\n\n\n<p>Let\u2019s start.<\/p>\n\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_76 counter-hierarchy ez-toc-counter ez-toc-custom ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/www.geoplugin.com\/resources\/what-is-geohashing-everything-you-need-to-know\/#How_Geohashing_Works\" >How Geohashing Works<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/www.geoplugin.com\/resources\/what-is-geohashing-everything-you-need-to-know\/#Step_1_Convert_LatitudeLongitude_Coordinates_to_Binary\" >Step 1: Convert Latitude\/Longitude Coordinates to Binary<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/www.geoplugin.com\/resources\/what-is-geohashing-everything-you-need-to-know\/#Step_2_Interleave_the_Binary_LatitudeLongitude_Values\" >Step 2: Interleave the Binary Latitude\/Longitude Values<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/www.geoplugin.com\/resources\/what-is-geohashing-everything-you-need-to-know\/#Step_3_Convert_Interleaved_Binary_String_to_Base32_String\" >Step 3: Convert Interleaved Binary String to Base32 String<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/www.geoplugin.com\/resources\/what-is-geohashing-everything-you-need-to-know\/#Demonstration_of_the_Steps\" >Demonstration of the Steps<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/www.geoplugin.com\/resources\/what-is-geohashing-everything-you-need-to-know\/#Step_1_Convert_the_Latitude_Value_3378764_Into_a_Binary_String\" >Step 1: Convert the Latitude Value (33.78764) Into a Binary String<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/www.geoplugin.com\/resources\/what-is-geohashing-everything-you-need-to-know\/#Step_2_Convert_the_Longitude_Value_-1181142_Into_a_Binary_String\" >Step 2: Convert the Longitude Value (-118.1142) Into a Binary String<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/www.geoplugin.com\/resources\/what-is-geohashing-everything-you-need-to-know\/#Step_3_Interleave_the_Latitude_and_Longitude_Binary_Strings\" >Step 3: Interleave the Latitude and Longitude Binary Strings<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/www.geoplugin.com\/resources\/what-is-geohashing-everything-you-need-to-know\/#Step_4_Convert_Interleaved_Binary_String_to_Base32_String\" >Step 4: Convert Interleaved Binary String to Base32 String<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-10\" href=\"https:\/\/www.geoplugin.com\/resources\/what-is-geohashing-everything-you-need-to-know\/#Geohashing_Precision\" >Geohashing Precision<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-11\" href=\"https:\/\/www.geoplugin.com\/resources\/what-is-geohashing-everything-you-need-to-know\/#Reasons_To_Use_Geohashing\" >Reasons To Use Geohashing<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-12\" href=\"https:\/\/www.geoplugin.com\/resources\/what-is-geohashing-everything-you-need-to-know\/#Where_Geohashing_Is_Used\" >Where Geohashing Is Used<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-13\" href=\"https:\/\/www.geoplugin.com\/resources\/what-is-geohashing-everything-you-need-to-know\/#Advantages_of_Geohashing\" >Advantages of Geohashing<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-14\" href=\"https:\/\/www.geoplugin.com\/resources\/what-is-geohashing-everything-you-need-to-know\/#Disadvantages_of_Geohashing\" >Disadvantages of Geohashing<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-15\" href=\"https:\/\/www.geoplugin.com\/resources\/what-is-geohashing-everything-you-need-to-know\/#Alternatives_to_Geohashing\" >Alternatives to Geohashing<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-16\" href=\"https:\/\/www.geoplugin.com\/resources\/what-is-geohashing-everything-you-need-to-know\/#Quadtrees_K-d_Trees\" >Quadtrees \/ K-d Trees<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-17\" href=\"https:\/\/www.geoplugin.com\/resources\/what-is-geohashing-everything-you-need-to-know\/#R-trees\" >R-trees<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-18\" href=\"https:\/\/www.geoplugin.com\/resources\/what-is-geohashing-everything-you-need-to-know\/#S2_Geometry\" >S2 Geometry<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-19\" href=\"https:\/\/www.geoplugin.com\/resources\/what-is-geohashing-everything-you-need-to-know\/#The_Bottom_Line\" >The Bottom Line<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-20\" href=\"https:\/\/www.geoplugin.com\/resources\/what-is-geohashing-everything-you-need-to-know\/#FAQs\" >FAQs<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-21\" href=\"https:\/\/www.geoplugin.com\/resources\/what-is-geohashing-everything-you-need-to-know\/#What_is_an_example_of_a_Geohash\" >What is an example of a Geohash?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-22\" href=\"https:\/\/www.geoplugin.com\/resources\/what-is-geohashing-everything-you-need-to-know\/#How_is_geohash_calculated\" >How is geohash calculated?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-23\" href=\"https:\/\/www.geoplugin.com\/resources\/what-is-geohashing-everything-you-need-to-know\/#What_is_the_shape_of_a_Geohash\" >What is the shape of a Geohash?<\/a><\/li><\/ul><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"How_Geohashing_Works\"><\/span>How Geohashing Works<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Below is the step-by-step process that explains exactly how geohashing works in detail.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Step_1_Convert_LatitudeLongitude_Coordinates_to_Binary\"><\/span>Step 1: Convert Latitude\/Longitude Coordinates to Binary<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>A coordinate system made of latitude and longitude ranges defines the boundaries of the planet.<\/p>\n\n\n\n<p>The latitude ranges from \u201390\u00b0 to +90\u00b0, and the longitude goes from \u2013180\u00b0 to +180\u00b0.<\/p>\n\n\n\n<p>A combination of numbers from these two ranges can describe any point on Earth.<\/p>\n\n\n\n<p>For instance, the (latitude, longitude) coordinates for the Walter Pyramid in California are 33.78764, -118.1142.<\/p>\n\n\n\n<p>The geohashing algorithm splits in half the geographical coordinates of a location repeatedly to come up with the geohash string.<\/p>\n\n\n\n<p>Each time the range is split in half, we record whether the coordinate falls in the upper or lower half.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>If your latitude is higher than the midpoint of \u201390\u00b0 and +90\u00b0, we mark it as 1.&nbsp;<\/li>\n<\/ul>\n\n\n\n<ul class=\"wp-block-list\">\n<li>If it\u2019s lower, it gets a 0.<\/li>\n<\/ul>\n\n\n\n<p>The same logic applies to longitude.&nbsp;<\/p>\n\n\n\n<p>Bit by bit, this gives you two binary strings, one for latitude and one for longitude.<\/p>\n\n\n\n<p>Now, the more we cut the ranges in half and record a binary bit, the longer the binary strings we get. And if we get longer strings, it means we get more precise locations.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"552\" height=\"356\" src=\"https:\/\/www.geoplugin.com\/resources\/wp-content\/uploads\/2025\/10\/2.png\" alt=\"The lat, long coordinates for the Walter Pyramid in California.\" class=\"wp-image-4031\" srcset=\"https:\/\/www.geoplugin.com\/resources\/wp-content\/uploads\/2025\/10\/2.png 552w, https:\/\/www.geoplugin.com\/resources\/wp-content\/uploads\/2025\/10\/2-300x193.png 300w\" sizes=\"auto, (max-width: 552px) 100vw, 552px\" \/><\/figure>\n<\/div>\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Step_2_Interleave_the_Binary_LatitudeLongitude_Values\"><\/span>Step 2: Interleave the Binary Latitude\/Longitude Values<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>Next, the geohashing algorithm interleaves the two binary strings from the previous step.&nbsp;<\/p>\n\n\n\n<p>That means it takes one bit from longitude, then one from latitude, then one from longitude again. It keeps alternating like that until we have a single longer binary string. The first bit will always be the longitude bit.<\/p>\n\n\n\n<p>This interleaving is what converts the two-dimensional data into one-dimensional data that databases can easily perform searches on.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Step_3_Convert_Interleaved_Binary_String_to_Base32_String\"><\/span>Step 3: Convert Interleaved Binary String to Base32 String<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>Now this binary string is also very long and inefficient for both humans and machines.&nbsp;&nbsp;<\/p>\n\n\n\n<p>So geohashing compresses it into a shorter and more readable string using Base32 encoding.<\/p>\n\n\n\n<p>For that, the binary string is split into 5-bit chunks. If your interleaved binary string is 20 bits long, you will have 4 5-bit chunks.<\/p>\n\n\n\n<p>Then, the algorithm converts each 5-bit chunk into a single Base32 character using this alphabet:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>0123456789bcdefghjkmnpqrstuvwxyz<\/li>\n<\/ul>\n\n\n\n<p><strong>Note:<\/strong> We skip the letters a, i, l, and o to avoid confusion with similar-looking digits like 1 and 0.<\/p>\n\n\n\n<p>This conversion gives us an alphanumeric string, which we call a geohash. The length of this geohash determines the geohash precision:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Fewer characters = a larger area (less precise)<\/li>\n\n\n\n<li>More characters = a smaller area (more precise)<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Demonstration_of_the_Steps\"><\/span>Demonstration of the Steps<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>We\u2019ve now gone through what is a geohash and how the geohashing algorithm works in theory. Now, it&#8217;s time to perform the steps on the geocodes of a location.&nbsp;<\/p>\n\n\n\n<p>How about I pick the coordinates of the Walter Pyramid (California) I mentioned before?&nbsp;<\/p>\n\n\n\n<p>Just to make you recall, its coordinates are 33.78764\u00b0, -118.1142\u00b0.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Step_1_Convert_the_Latitude_Value_3378764_Into_a_Binary_String\"><\/span>Step 1: Convert the Latitude Value (33.78764) Into a Binary String<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>We have the latitude value of 33.78764, and we know that latitude can range from -90 to +90.<\/p>\n\n\n\n<p>We will start by comparing the midpoint of the initial range, [-90, +90], which is 0. Then, we will compare it with our latitude value.<\/p>\n\n\n\n<p>By this comparison, we\u2019ll find whether our latitude lies in the upper or lower half of the range [-90, +90].<\/p>\n\n\n\n<p>If our latitude lies in the upper half (meaning it is greater than the midpoint)? We add the digit 1 to our binary string, and shorten the range accordingly. Otherwise, we get the digit 0.<\/p>\n\n\n\n<p>So let\u2019s start.<\/p>\n\n\n\n<figure class=\"wp-block-table is-style-regular\"><table class=\"has-fixed-layout\"><tbody><tr><td><strong>Iteration no.<\/strong><\/td><td><strong>Initial range<\/strong><\/td><td><strong>Midpoint<\/strong><\/td><td><strong>Latitude vs Midpoint<\/strong><\/td><td><strong>Binary digit<\/strong><\/td><td><strong>New range<\/strong><\/td><\/tr><tr><td>1<\/td><td>[-90, +90]<\/td><td>0<\/td><td>33.78764 &gt; 0<\/td><td>1<\/td><td>[0, +90]<\/td><\/tr><tr><td>2<\/td><td>[0, +90]<\/td><td>45<\/td><td>33.78764 &lt; 45<\/td><td>0<\/td><td>[0, 45]<\/td><\/tr><tr><td>3<\/td><td>[0, 45]<\/td><td>22.5<\/td><td>33.78764 &gt; 22.5<\/td><td>1<\/td><td>[22.5, 45]<\/td><\/tr><tr><td>4<\/td><td>[22.5, 45]<\/td><td>33.75<\/td><td>33.78764 &gt; 33.75<\/td><td>1<\/td><td>[33.75, 45]<\/td><\/tr><tr><td>5<\/td><td>[33.75, 45]<\/td><td>39.375<\/td><td>33.78764 &lt; 39.375<\/td><td>0<\/td><td>[33.75, 39.375]<\/td><\/tr><tr><td>6<\/td><td>[33.75, 39.375]<\/td><td>36.5625<\/td><td>33.78764 &lt; 36.5625<\/td><td>0<\/td><td>[33.75, 36.5625]<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>I performed 6 iterations for the sake of this demo. The values of the Binary digit column will form our binary string for the latitude.<\/p>\n\n\n\n<p>After ten iterations, our latitude binary string will be 1011000000. You can perform more or fewer iterations based on the level of precision you need.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Step_2_Convert_the_Longitude_Value_-1181142_Into_a_Binary_String\"><\/span>Step 2: Convert the Longitude Value (-118.1142) Into a Binary String<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>Now, let\u2019s repeat the same steps for our longitude value -118.1142.<\/p>\n\n\n\n<p>A longitude value can range from [-180, +180], so that will be our initial range.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><td><strong>Iteration no.<\/strong><\/td><td><strong>Initial range<\/strong><\/td><td><strong>Midpoint<\/strong><\/td><td><strong>Longitude vs Midpoint<\/strong><\/td><td><strong>Binary digit<\/strong><\/td><td><strong>New range<\/strong><\/td><\/tr><tr><td>1<\/td><td>[-180, 180]<\/td><td>0<\/td><td>-118.1142 &lt; 0<\/td><td>0<\/td><td>[-180, 0]<\/td><\/tr><tr><td>2<\/td><td>[-180, 0]<\/td><td>-90<\/td><td>-118.1142 &lt; -90<\/td><td>0<\/td><td>[-180, -90]<\/td><\/tr><tr><td>3<\/td><td>[-180, -90]<\/td><td>-135<\/td><td>-118.1142 &gt; -135<\/td><td>1<\/td><td>[-135, -90]<\/td><\/tr><tr><td>4<\/td><td>[-135, -90]<\/td><td>-112.5<\/td><td>-118.1142 &lt; -112.5<\/td><td>0<\/td><td>[-135, -112.5]<\/td><\/tr><tr><td>5<\/td><td>[-135, -112.5]<\/td><td>-123.75<\/td><td>-118.1142 &gt; -123.75<\/td><td>1<\/td><td>[-123.75, -112.5]<\/td><\/tr><tr><td>6<\/td><td>[-123.75, -112.5]<\/td><td>-118.125<\/td><td>-118.1142 &gt; -118.125<\/td><td>1<\/td><td>[-118.125, -112.5]<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>After ten iterations, our binary string for longitude will be 0010110000.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Step_3_Interleave_the_Latitude_and_Longitude_Binary_Strings\"><\/span>Step 3: Interleave the Latitude and Longitude Binary Strings<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>This is the easy step. We will interleave the latitude and longitude strings to form a single string.<\/p>\n\n\n\n<p>We simply need to alternate one bit from longitude, then one from latitude, and so on.<\/p>\n\n\n\n<p>The pattern is lon\u2081, lat\u2081, lon\u2082, lat\u2082, lon\u2083, lat\u2083, \u2026<\/p>\n\n\n\n<p>The first bit will always be the longitude bit.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Our longitude is:<\/strong> 0010110000<\/li>\n\n\n\n<li><strong>Our latitude is:<\/strong> 1011000000<\/li>\n<\/ul>\n\n\n\n<p>The resulting 20-bit interleaved sequence will be:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>10001110010100000000<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Step_4_Convert_Interleaved_Binary_String_to_Base32_String\"><\/span>Step 4: Convert Interleaved Binary String to Base32 String<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>Lastly, we\u2019ll make 5-bit chunks of our interleaved string for Base32 encoding:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><td><strong>5-bit Group<\/strong><\/td><td><strong>Calculation<\/strong><\/td><td><strong>Decimal Value<\/strong><\/td><td><strong>Base32 Char<\/strong><\/td><\/tr><tr><td>10001<\/td><td>(16 + 0 + 0 + 0 + 1)<\/td><td>17<\/td><td>j<\/td><\/tr><tr><td>11001<\/td><td>(16 + 8 + 0 + 0 + 1)<\/td><td>25<\/td><td>t<\/td><\/tr><tr><td>01010<\/td><td>(0 + 8 + 0 + 2 + 0)<\/td><td>10<\/td><td>b<\/td><\/tr><tr><td>00000<\/td><td>(0)<\/td><td>0<\/td><td>0<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>After putting the Base32 characters together, we finally get our geohash: <strong>jtb0<\/strong>.<\/p>\n\n\n\n<p>So the geohash for the coordinates 33.78764\u00b0, -118.1142\u00b0 is <strong>jtb0<\/strong>.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"507\" height=\"422\" src=\"https:\/\/www.geoplugin.com\/resources\/wp-content\/uploads\/2025\/10\/3.png\" alt=\"A 4 character long geohash.\" class=\"wp-image-4036\" srcset=\"https:\/\/www.geoplugin.com\/resources\/wp-content\/uploads\/2025\/10\/3.png 507w, https:\/\/www.geoplugin.com\/resources\/wp-content\/uploads\/2025\/10\/3-300x250.png 300w\" sizes=\"auto, (max-width: 507px) 100vw, 507px\" \/><\/figure>\n<\/div>\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Geohashing_Precision\"><\/span>Geohashing Precision<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>You can control the precision of a geohash by adding or removing a number from it.<\/p>\n\n\n\n<p>When you add a character to its end, the location narrows down to a smaller area. And when you delete a character from its ending, the resulting geohash points to a broader region.<\/p>\n\n\n\n<p>For instance, the image above shows how much area a 4-character-long geohash, <strong>9qh0<\/strong>, represents.<\/p>\n\n\n\n<p>Increasing the precision of the same geohash to 5 characters zooms into the Anaheim city (see the image below).<\/p>\n\n\n\n<p>Here\u2019s a general idea of how geohash precision works as the code length increases:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>1 character:<\/strong> ~Continent-sized area<\/li>\n\n\n\n<li><strong>2 characters:<\/strong> ~Region about the size of Western Europe<\/li>\n\n\n\n<li><strong>3 characters:<\/strong> ~Size of a city<\/li>\n\n\n\n<li><strong>4 characters:<\/strong> ~A district or neighborhood<\/li>\n\n\n\n<li><strong>5 characters:<\/strong> ~A town<\/li>\n\n\n\n<li><strong>6 characters:<\/strong> ~A city block<\/li>\n\n\n\n<li><strong>7 characters:<\/strong> ~Street or large building<\/li>\n\n\n\n<li><strong>8 characters:<\/strong> ~A building or parcel of land<\/li>\n\n\n\n<li><strong>9 characters:<\/strong> ~A specific part of a parking lot<\/li>\n<\/ul>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"507\" height=\"422\" src=\"https:\/\/www.geoplugin.com\/resources\/wp-content\/uploads\/2025\/10\/4.png\" alt=\"A 5 character long geohash.\" class=\"wp-image-4039\" srcset=\"https:\/\/www.geoplugin.com\/resources\/wp-content\/uploads\/2025\/10\/4.png 507w, https:\/\/www.geoplugin.com\/resources\/wp-content\/uploads\/2025\/10\/4-300x250.png 300w\" sizes=\"auto, (max-width: 507px) 100vw, 507px\" \/><\/figure>\n<\/div>\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Reasons_To_Use_Geohashing\"><\/span>Reasons To Use Geohashing<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Here are two main reasons to use geohashing.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Faster proximity searches:<\/strong> Geohashes free you from depending on heavy latitude and longitude ranges for performing proximity searches. The geographic neighbors of a geohash have similar prefixes, making it easy to compare the prefixes to find nearby points.<\/li>\n\n\n\n<li><strong>Efficient database indexing:<\/strong> Geohashes don\u2019t contain decimal floating points because, unlike latitude and longitudes, they\u2019re strings. It makes them efficient for your standard database, which is good at handling strings.<\/li>\n<\/ul>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"186\" height=\"142\" src=\"https:\/\/www.geoplugin.com\/resources\/wp-content\/uploads\/2025\/10\/5.png\" alt=\"A text showing \u201cNeighbours:\u201d followed by geohash codes.\" class=\"wp-image-4041\" style=\"width:186px;height:auto\"\/><\/figure>\n<\/div>\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Where_Geohashing_Is_Used\"><\/span>Where Geohashing Is Used<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Geohashing sees a huge usage in modern location-based services.&nbsp;<\/p>\n\n\n\n<p>Here are two of its major applications:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Geospatial databases:<\/strong> Many <a href=\"https:\/\/www.geoplugin.com\/resources\/free-ip-geolocation-database-everything-you-need-to-know\/\">databases<\/a> use geohashing to handle location-based queries for spatial indexing. With this kind of spatial indexing, queries like \u201cfind all points within a radius\u201d run faster than traditional 2D searches.<\/li>\n<\/ul>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Ridesharing and food delivery platforms:<\/strong> All ridesharing apps you have used to date have geohashing under the hood. The apps use geohashing to group drivers and riders into spatial buckets based on their current location. When you request a ride, the system looks for riders in the same or neighboring geohash cells. The same goes for food delivery apps. Instead of riders, they fetch all restaurants near your geohash cell.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Advantages_of_Geohashing\"><\/span>Advantages of Geohashing<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Some benefits that geohashing offers include:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Hierarchical zooming:<\/strong> You can zoom in or zoom out of a map just by adjusting the number of characters in a geohash. To zoom in, you need to add a valid character to the geohash string. To zoom out, simply remove trailing characters to make the geohash shorter.&nbsp;<\/li>\n<\/ul>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Built for scale:<\/strong> Geohashing optimizes both storage and query speed. Why? Well, because nearby locations share common prefixes, it makes it easy to shard data across servers.<\/li>\n<\/ul>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Database agnostic flexibility:<\/strong> Geohashes are compatible with any database that supports string indexing, and there are many of them. PostgreSQL, MySQL, and MongoDB are just a few examples.<\/li>\n\n\n\n<li><strong>Compact and storage-efficient:<\/strong> Storing and sharing row floating point coordinates takes up more storage and space than short alphanumeric strings. This is why geohashes are ideal for APIs, URLs, and social media.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Disadvantages_of_Geohashing\"><\/span>Disadvantages of Geohashing<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>While geohashing offers solutions for some big inefficiencies, it brings its fair share of limitations, like all algorithms.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Uneven spatial distribution: <\/strong>The geohashing algorithm divides the world into rectangular grids, but this doesn\u2019t perfectly match Earth\u2019s curved and elliptical surface. This causes uneven spatial distribution, especially near the poles. For instance, when the latitude increases, geohash cells distort in size and result in slightly skewed proximity calculations.&nbsp;<\/li>\n\n\n\n<li><strong>Rigid grid boundaries: <\/strong>Let\u2019s say two nearby points are lying on opposite sides of a boundary connecting two rectangular cells. When you run a proximity-based query on any one of these points, you overlook the nearby point in the adjacent cell. Simply because it isn\u2019t in the same cell.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Alternatives_to_Geohashing\"><\/span>Alternatives to Geohashing<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Geohashing isn\u2019t the only method for spatial indexing. There are other popular systems as well.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"800\" height=\"800\" src=\"https:\/\/www.geoplugin.com\/resources\/wp-content\/uploads\/2025\/10\/6.png\" alt=\"Blue quadtree grid with small black circles clustered in corners and sparse in the center on a transparent background.\" class=\"wp-image-4044\" srcset=\"https:\/\/www.geoplugin.com\/resources\/wp-content\/uploads\/2025\/10\/6.png 800w, https:\/\/www.geoplugin.com\/resources\/wp-content\/uploads\/2025\/10\/6-300x300.png 300w, https:\/\/www.geoplugin.com\/resources\/wp-content\/uploads\/2025\/10\/6-150x150.png 150w, https:\/\/www.geoplugin.com\/resources\/wp-content\/uploads\/2025\/10\/6-768x768.png 768w\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" \/><\/figure>\n<\/div>\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Quadtrees_K-d_Trees\"><\/span>Quadtrees \/ K-d Trees<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>A Quadtree is a tree data structure that partitions a two-dimensional space by recursively subdividing it into four quadrants.&nbsp;<\/p>\n\n\n\n<p>It mainly differs from geohashing due to conditional subdivision. In geohashing, we divide the world into a fixed grid.<\/p>\n\n\n\n<p>But in quadtrees, we divide a space based on a specific rule. For instance, we subdivide areas with more data.<\/p>\n\n\n\n<p>In the real world, this dynamic subdivision helps in cases of biomes where high precision isn\u2019t needed, like deserts\/oceans.<\/p>\n\n\n\n<p>The K-d tree data structure, on the other hand, performs recursive binary space partitioning along alternating axes.<\/p>\n\n\n\n<p>K-d trees also adapt to data density, similar to quadtrees.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"828\" height=\"828\" src=\"https:\/\/www.geoplugin.com\/resources\/wp-content\/uploads\/2025\/10\/7.png\" alt=\"A 2D grid showing k-d tree space partitions with colored regions, dashed split lines, and circular split nodes.\" class=\"wp-image-4046\" srcset=\"https:\/\/www.geoplugin.com\/resources\/wp-content\/uploads\/2025\/10\/7.png 828w, https:\/\/www.geoplugin.com\/resources\/wp-content\/uploads\/2025\/10\/7-300x300.png 300w, https:\/\/www.geoplugin.com\/resources\/wp-content\/uploads\/2025\/10\/7-150x150.png 150w, https:\/\/www.geoplugin.com\/resources\/wp-content\/uploads\/2025\/10\/7-768x768.png 768w\" sizes=\"auto, (max-width: 828px) 100vw, 828px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"R-trees\"><\/span>R-trees<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>R-trees start from the bottom.<\/p>\n\n\n\n<p>It groups nearby geographic objects like cities, rivers, and parks by drawing the smallest possible box around them.<\/p>\n\n\n\n<p>Then, it nests these boxes inside larger boxes that represent the larger area around the smaller boxes.<\/p>\n\n\n\n<p>Since R-trees work on the object level, their boxes can be of arbitrary shapes and sizes.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"828\" height=\"456\" src=\"https:\/\/www.geoplugin.com\/resources\/wp-content\/uploads\/2025\/10\/8.png\" alt=\"A map showing R-tree spatial indexing with highlighted bounding boxes over Manhattan street network.\" class=\"wp-image-4050\" srcset=\"https:\/\/www.geoplugin.com\/resources\/wp-content\/uploads\/2025\/10\/8.png 828w, https:\/\/www.geoplugin.com\/resources\/wp-content\/uploads\/2025\/10\/8-300x165.png 300w, https:\/\/www.geoplugin.com\/resources\/wp-content\/uploads\/2025\/10\/8-768x423.png 768w\" sizes=\"auto, (max-width: 828px) 100vw, 828px\" \/><\/figure>\n<\/div>\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"S2_Geometry\"><\/span>S2 Geometry<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>Google\u2019s S2 Geometry places the earth inside a circumscribed cube. The sphere touches the cube at the center of each face.<\/p>\n\n\n\n<p>Then, it performs a gnomonic projection. In simple words, this projects every point on the Earth&#8217;s surface radially outward onto the cube&#8217;s faces.<\/p>\n\n\n\n<p>This creates a hierarchy of cells that cover the globe with minimal distortion.<\/p>\n\n\n\n<p>S2 geometry then uses quadtrees to subdivide each face of the cube.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"778\" height=\"376\" src=\"https:\/\/www.geoplugin.com\/resources\/wp-content\/uploads\/2025\/10\/9-1.png\" alt=\"S2 Geometry world map showing cell divisions and face boundaries across continents and oceans. \" class=\"wp-image-4053\" srcset=\"https:\/\/www.geoplugin.com\/resources\/wp-content\/uploads\/2025\/10\/9-1.png 778w, https:\/\/www.geoplugin.com\/resources\/wp-content\/uploads\/2025\/10\/9-1-300x145.png 300w, https:\/\/www.geoplugin.com\/resources\/wp-content\/uploads\/2025\/10\/9-1-768x371.png 768w\" sizes=\"auto, (max-width: 778px) 100vw, 778px\" \/><\/figure>\n<\/div>\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"The_Bottom_Line\"><\/span>The Bottom Line<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Geohashing offers a great way to turn 2D data into linear data for easy and, most importantly, hassle-free querying. While it has some issues like the edge case inaccuracy, it still sees popular usage in mainstream applications.<\/p>\n\n\n\n<p>Besides geohashing, we also explored other alternatives that subdivide the world in their own ways.<\/p>\n\n\n\n<p>Speaking of geography, GeoPlugin is a geolocation tool that can determine geographical details based on <a href=\"https:\/\/www.geoplugin.com\/resources\/types-of-ip-address-functions-and-uses-of-different-ips\/\">IP addresses<\/a>.&nbsp;<\/p>\n\n\n\n<p>Website owners can use this to segment their visitors and dynamically change their website\u2019s UI to offer personalized experiences.<\/p>\n\n\n\n<p>Explore GeoPlugin to start <a href=\"https:\/\/www.geoplugin.com\/ip-location-lookup-api\" title=\"geolocating IPs with our API\">geolocating IPs with our API<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"FAQs\"><\/span>FAQs<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<div data-schema-only=\"false\" class=\"wp-block-aioseo-faq\"><h3 class=\"aioseo-faq-block-question\"><span class=\"ez-toc-section\" id=\"What_is_an_example_of_a_Geohash\"><\/span>What is an example of a Geohash?<span class=\"ez-toc-section-end\"><\/span><\/h3><div class=\"aioseo-faq-block-answer\">\n<p>A geohash is a string that is alphanumeric in nature and points to a region. The more characters in a geohash, the more precise the area it points to. For instance, the Charging Bull sculpture in New York has the geohash dr5ref.<\/p>\n<\/div><\/div>\n\n\n\n<div data-schema-only=\"false\" class=\"wp-block-aioseo-faq\"><h3 class=\"aioseo-faq-block-question\"><span class=\"ez-toc-section\" id=\"How_is_geohash_calculated\"><\/span>How is geohash calculated?<span class=\"ez-toc-section-end\"><\/span><\/h3><div class=\"aioseo-faq-block-answer\">\n<p>You calculate the geohash of a location on Earth by converting its latitude and longitude values into two binary strings. Then you can form a single binary string by interleaving the two strings. In the last, you perform Base32 encoding on the resulting string to get the geohash.<\/p>\n<\/div><\/div>\n\n\n\n<div data-schema-only=\"false\" class=\"wp-block-aioseo-faq\"><h3 class=\"aioseo-faq-block-question\"><span class=\"ez-toc-section\" id=\"What_is_the_shape_of_a_Geohash\"><\/span>What is the shape of a Geohash?<span class=\"ez-toc-section-end\"><\/span><\/h3><div class=\"aioseo-faq-block-answer\">\n<p>When we talk about Geohash\u2019s geometry, it has a mixed spatial representation. The exact shape of a geohash is rectangular with 32 subrectangles inside.<br><\/p>\n<\/div><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Have you ever wondered how your ride-sharing app finds riders only nearby instead of the entire city? How does this happen at an algorithmic level? You might think the system simply compares your (the user&#8217;s) geographical coordinates with those of drivers. But this approach requires scanning the coordinates of all drivers in the database to&hellip; <a class=\"more-link\" href=\"https:\/\/www.geoplugin.com\/resources\/what-is-geohashing-everything-you-need-to-know\/\">Continue reading <span class=\"screen-reader-text\">What Is Geohashing? Everything You Need To Know<\/span><\/a><\/p>\n","protected":false},"author":9,"featured_media":4028,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-4027","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-geolocation","entry"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.geoplugin.com\/resources\/wp-json\/wp\/v2\/posts\/4027","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.geoplugin.com\/resources\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.geoplugin.com\/resources\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.geoplugin.com\/resources\/wp-json\/wp\/v2\/users\/9"}],"replies":[{"embeddable":true,"href":"https:\/\/www.geoplugin.com\/resources\/wp-json\/wp\/v2\/comments?post=4027"}],"version-history":[{"count":12,"href":"https:\/\/www.geoplugin.com\/resources\/wp-json\/wp\/v2\/posts\/4027\/revisions"}],"predecessor-version":[{"id":4421,"href":"https:\/\/www.geoplugin.com\/resources\/wp-json\/wp\/v2\/posts\/4027\/revisions\/4421"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.geoplugin.com\/resources\/wp-json\/wp\/v2\/media\/4028"}],"wp:attachment":[{"href":"https:\/\/www.geoplugin.com\/resources\/wp-json\/wp\/v2\/media?parent=4027"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.geoplugin.com\/resources\/wp-json\/wp\/v2\/categories?post=4027"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.geoplugin.com\/resources\/wp-json\/wp\/v2\/tags?post=4027"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}