I'm trying to learn a bit of CartoDB by creating a heatmap using crime data available on the city's website where the raw number of crimes are displayed for each police district.

So far I've been able to draw the district polygon shapes, assign the data for several crimes to each district, and create visualizations for each set of data using the chloropleth style, and toggle different vizualizations on a map using cartodb.js.

Before I move forward with adding the remaining crime data (50+ categories) for multiple years I'm hoping to learn a bit of best practices.

crime map which pulls in multiple visualizations

Should I be using layers/sublayers or multiple visualizations to display crime rates using CartoDB?

The main reason for asking is that some crimes like curfew/loitering have 1000+ incidents, whereas others like murder or rape have 0 or 1 for an entire year and I want to be sure I'm representing the severity properly.

  • Interesting question. I have been working on something similar. My thoughts are that you can't really mix different crime types in same output, unless perhaps they are expressed as standard deviations (or normalized somehow) from a historical trend. Mar 13, 2015 at 12:26

1 Answer 1


there are a variety of ways that your data can be visualized in CartoDB. First, of you are trying to create a heat map that shows concentrations of crimes in space, and you are working with point data, the 'heat map' option in the editor is going to be a more accurate choice for this. If you want to make a choropleth, it is important that your data is normalized by either space or number of residents (per 100,000 residents for example) to avoid inconsistencies across districts based on size compared to population count.

If all of your data is in one table, you can use the SQL API to view different combinations of information or you can add each crime as a different layer, then create a layer selector (Which sounds like with the amount of data you have may not be possible). If you have huge differences in the numbers between crimes, you may want to consider adding a legend toggle that accurately shows the count of each crime layer or SQL statement when selected.

I recently built a map similar to what you are trying to do using a layer selector and custom legends using CartoDB.js. You can check it out here.

Hope this helps!

  • This set of data gives a district number and the raw number of crimes for each category of crime within them. I used a district map graphic to draw the districts and am joining the crime data with the map boundaries. My first try used separate layers but could only use a maximum of 4 layers and there are 50+ crime categories. This map is great and looks like it uses more than 10 layers (maybe not though); I wasn't sure if that was a possibility using cartodb.js: nyc.pediacities.com/fsmaps/NYCCrimeMap It seems like pulling in individual visualizations might be the best bet.
    – Stephen S.
    Mar 13, 2015 at 21:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.