# Tiling geographic regions

**URL:** <https://racket.discourse.group/t/tiling-geographic-regions/1255>\
**Category:** Show & Tell\
**Created:** [August 25, 2022, 1:09pm UTC](https://racket.discourse.group/t/tiling-geographic-regions/1255 "2022-08-25T13:09:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![alexh](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/alexh/32/315_2.png) [@alexh](https://racket.discourse.group/u/alexh)\
**Post date:** [August 25, 2022, 1:09pm UTC](https://racket.discourse.group/t/tiling-geographic-regions/1255/1 "2022-08-25T13:09:19Z")

</div>

![tiling-australia](https://global.discourse-cdn.com/free1/uploads/racket/original/1X/9c6db8dd768d3c1369c0719fe01334925b3f3848.png)

So, I updated my geoid package to support region tiling. This is the process of subdividing any region on the globe into a list of squares which are uniquely identified using 64 bit numbers -- this effectively changes and "point in region" tests into finding if an integer is in a list of sorted integers, an operation which is extremely fast even for regions of arbitrary complexity.

This can be used to create fast indexes for geographic regions and I used it to update the tzgelookup package and make it about 10 times faster (the tzgeolookup package determines the time zone for a latitude/longitude coordinate).

This has been an interesting project for me (and I wasted too much time on it), but among other things it required me to to strict equality tests on floating point numbers, as well as write a distributed tiling process and run it on all the laptops I found in my house, since I was too cheap to rent VMs on a cloud provider 🙂

I wrote some more notes about it here:

> **[Timezone Lookup Revisited](https://alex-hhh.github.io/2022/08/timezone-lookup-revisited.html)**
>
> in which we look at how to really speed up the lookup of geographic locations in a large number or regions covering the entire Earth surface. This is the problem that the tzgeolookup package has to solve: given a geographic location it needs to...

Alex.

---

<div class="post-metadata">

**Author:** ![simonls](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/simonls/32/170_2.png) [@simonls](https://racket.discourse.group/u/simonls)\
**Post date:** [August 25, 2022, 1:29pm UTC](https://racket.discourse.group/t/tiling-geographic-regions/1255/2 "2022-08-25T13:29:15Z")

</div>

I also like how the squares reveal some of the "warping" between the real world coordinates and the 2D map projection.

---

<div class="post-metadata">

**Author:** ![alexh](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/alexh/32/315_2.png) [@alexh](https://racket.discourse.group/u/alexh)\
**Post date:** [August 26, 2022, 12:46pm UTC](https://racket.discourse.group/t/tiling-geographic-regions/1255/3 "2022-08-26T12:46:47Z")

</div>

Yes, the geoids don't look like rectangles on a Mercator projection map, perhaps the most extreme example is the covering for the "Antarctica/McMurdo" zone which covers the south pole:

 ![image](https://global.discourse-cdn.com/free1/uploads/racket/original/1X/de929d6cf0c32e9a2e7d5c780d173acd1cc00e93.jpeg)

However, they really are square when projected onto a plane tangent to the south pole:

 ![image](https://global.discourse-cdn.com/free1/uploads/racket/original/1X/79450b2ebbdef70d5b2f504c0f8ecbf8c42b142c.png)

Alex.
