# Extending the hexagonal world notebook

**URL:** <https://talk.observablehq.com/t/extending-the-hexagonal-world-notebook/1646>\
**Category:** Help\
**Created:** [February 5, 2019, 4:13pm UTC](https://talk.observablehq.com/t/extending-the-hexagonal-world-notebook/1646 "2019-02-05T16:13:58Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![rezpe](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/rezpe/32/1422_2.png) [@rezpe](https://talk.observablehq.com/u/rezpe)\
**Post date:** [February 5, 2019, 4:13pm UTC](https://talk.observablehq.com/t/extending-the-hexagonal-world-notebook/1646/1 "2019-02-05T16:13:58Z")

</div>

Hi,

I just saw the great work from Nadieh Bremer and Mike Bostock using pointinpath for maps. As an example:

> **[Hexagonal World](https://beta.observablehq.com/@mbostock/hexagonal-world)**
>
> An Observable notebook by Mike Bostock.

I was wondering if that can be extended to add hexagons whose class depends on the country they are touching ? If this could be done and in combination with cartograms, it would allow to create tilegrams: [https://pitchinteractiveinc.github.io/tilegrams/](https://pitchinteractiveinc.github.io/tilegrams/) automatically.

Please could you help me or point me to ressources to do that? I believe that would be a great contribution.

Thanks !!

---

<div class="post-metadata">

**Author:** ![rezpe](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/rezpe/32/1422_2.png) [@rezpe](https://talk.observablehq.com/u/rezpe)\
**Post date:** [February 5, 2019, 4:16pm UTC](https://talk.observablehq.com/t/extending-the-hexagonal-world-notebook/1646/2 "2019-02-05T16:16:17Z")

</div>

Perhaps it would be possible to iterate through all the features of the topojson and then execute the ispointinpath ?

---

<div class="post-metadata">

**Author:** ![bgchen](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/bgchen/32/784_2.png) [@bgchen](https://talk.observablehq.com/u/bgchen)\
**Post date:** [February 5, 2019, 4:39pm UTC](https://talk.observablehq.com/t/extending-the-hexagonal-world-notebook/1646/3 "2019-02-05T16:39:55Z")

</div>

Fun idea! Here’s a really sloppy take on it:

> **[Observable](https://beta.observablehq.com/d/d1e837397ccac837)**
>
> A better way to code.

Diff:

> **[Comparing ‘Hexagonal World’ by Mike Bostock to ‘Hexagonal World (coloring by...](https://beta.observablehq.com/compare/aa14b1856150505d...d1e837397ccac837)**
>
> A comparison of two Observable notebooks.

edit: All I did in this edit was to change the cells so that they iterated over the 177 country features sitting inside `world.objects.countries` instead of just the one feature in `world.objects.land`. The current notebook uses canvas to draw the map, so to carry your original idea in full (i.e. to assign classes to hexagons), you’d need to write a function which generates hexagonal svg paths at the end.

To do this automatically with cartograms would be trickier. One issue is that the discretization performed by using `isPointInPath` is not going to be very accurate, which could lead to something misleading. See also the comments under “Ensuring statistical accuracy” in the manual of the tilegram page that you linked.

---

<div class="post-metadata">

**Author:** ![rezpe](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/rezpe/32/1422_2.png) [@rezpe](https://talk.observablehq.com/u/rezpe)\
**Post date:** [February 7, 2019, 9:08am UTC](https://talk.observablehq.com/t/extending-the-hexagonal-world-notebook/1646/4 "2019-02-07T09:08:16Z")

</div>

Wow,

Really cool !!! Thanks a lot. I will try to combine this with cartogram: [https://beta.observablehq.com/@bumbeishvili/population-change-over-years-in-georgias-regions](https://beta.observablehq.com/@bumbeishvili/population-change-over-years-in-georgias-regions).  
Let’s see. I’ll let you know in this thread !

Sebas
