Data Classification and Color Theory with ClassyBrew

When creating a choropleth map, there are generally two key questions.

How do I classify the data? (break up the data)

What color scheme should be used?

Data Classification

If you ever classified data using GIS desktop software or a capable API like Esri’s Javascript API, you’ve been lucky to have this already solved for you. A quick selection of an appropriate data classification, such as: equal area, natural breaks, quantile, standard deviation, etc. will provide you with breaks in your data. Once your data is classified you can define how you want to symbolize your data by color, or select any available color palettes. You still need to answer the above questions, but all the tools are ready at your disposal.

My favorite data classification method is called the Jenks Natural Breaks method. It calculates inherent places to break up your data based on the number of classes you want. These statistically related numeric ranges are perfect for a when you want a meaningful breakup of you data. If you are looking for an amazing writeup of the Jenks Natural Breaks, and an algorithm in Python, read the following blog post by Daniel Lewis:

I started to break down the algorithim into javascript, until I blindly stumbled geostats, a comprehensive open source library provided by Simon Georget. Geostats is a standalone library that provides methods to classify your data using various different methodoligies, including Jenks Natural Breaks. If you are looking for a multipurpose tool, I would defintely consider incorporating it into your future projects.

Color Theory

What colors best represent your newly classified data? More often than most, you will be classifying your data because it follows some sequential pattern. Cynthia Brewer has spend a good chunk of her career figuring this out for you. Thank you Cynthia! Her research and cartographical background created COLORBREWER, a visual decision making tool for coloring your map to represent your data.

The Problem

I recently created a map in Leaflet and needed to classify my data (geojson) and assign a color value to each sequential range. Since there is no inherent ability to render data based on associated values, you will need to do this from scratch. I found a handy chropleth example on Leaflet that did just that.

This was accomplished by manually defining your breaks and returning , again a manually assigned color: