1

I have a categorical Carto map that shows the different types of industrial accidents, but I also want to differentiate the points based on the number of deaths i.e. the higher number of deaths, the bigger the marker width.

This is the CSS style, but I am not sure why I keep encountering an error when I apply the style.

 #layer {
   marker-width: 6.5;
   marker-fill: ramp([type_of_accidents], (#311271, #1D6996, #129C63, #73AF48, #EDAD08, #E17C05, #C94034), category(7));
   marker-fill-opacity: 0.5;
   marker-allow-overlap: true;
   marker-line-width: 1;
   marker-line-color: #FFF;
   marker-line-opacity: 1;
 }
 #no_of_deaths [ value <= 5] {
 marker-width: 5.0;
 }
 #no_of_deaths [ value <= 20] {
 marker-width: 15;
 }
 #no_of_deaths [ value <= 40] {
 marker-width: 25;
 }
2

Styling by value using two variables can be done directly from BUILDER UI, here you have a GUIDE explaining how to do it. But if you want to use CartoCSS, the right code would be something like this:

#layer {
   marker-width: ramp([number_of_deaths], (5,20,40), jenks(), <=);
   marker-fill: ramp([type_of_accidents], (#311271, #1D6996, #129C63, #73AF48, #EDAD08, #E17C05, #C94034), category(7));
   marker-fill-opacity: 0.5;
   marker-allow-overlap: true;
   marker-line-width: 1;
   marker-line-color: #FFF;
   marker-line-opacity: 1;
 }

Here you have a blog post that explains how to style using Turbo carto. Cheers!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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