# Create your own hexamaps

**Renglish – 56north | Skræddersyet dataanalyse**, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)

Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Hexamaps are gaining in popularity. Most notably has been the versions, where the map of the USA has been made into a hexamap. But people have also made maps of Europe using hexagons.

The idea is that one unit is one hexagon. So in case of the US, each state is one hexagon. In the case of Europe, each country is a hexagon.

This means that all units (states, countries, etc.) are the same size. This of course skews the hexamap in relation to the real geographic proportions. But it gives the advantage of giving all units equal size for displaying information – for instance a shade or color depending on some underlying values.

I have made a hexamap of the municipalities in Denmark. The capital region is very dense so I had to sort of map that on the side. You can see my efforts here:

To ease the process I’ve made the hexamapmaker package. It takes a set of points and turns them into hexagons. That means that you can quickly and easily design and produce hexamaps.

Below I’ve included the example code from the package if you want to get started yourself. If you create a map of your own please share it with me on twitter @mikkelkrogsholm. I’d love to see your work!

# Install hexamapmaker

devtools::install_github(“56north/hexamapmaker”)

library(hexamapmaker)

# Create data frame

# Notice the spacing of the points

x <- c(1,3,2,4,1,3,7,8)

y <- c(1,1,3,3,5,5,1,3)

id <- c(“test1”, “test2”, “test3”, “test4”, “test5”, “test6”, “test7”, “test8″)

z <- data.frame(id,x,y)

# Plot points

library(ggplot2)

ggplot(z, aes(x, y, group = id)) +

geom_point() +

coord_fixed(ratio = 1) +

ylim(0,max(y)) + xlim(0,max(x))

# Turn points into hexagons

library(hexamapmaker)

zz <- hexamap(z)

ggplot(zz, aes(x, y, group = id)) +

geom_polygon(colour=”black”, fill = NA) +

coord_fixed(ratio = 1)

**leave a comment**for the author, please follow the link and comment on their blog:

**Renglish – 56north | Skræddersyet dataanalyse**.

R-bloggers.com offers

**daily e-mail updates**about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.

Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.