2

I have a set of field measurements for a bird species (pitch of its song) along with coordinates for each measurement.

The default choropleth style in CARTO works perfectly for showing how the pitch varies across its geographic distribution (see image; red means higher pitch). However, many of my data points overlap. How can I cluster them together and display the average pitch for overlapping points in choropleth-style?

Pitch of bird song from high (red) to low (yellow).

0

Please follow these steps in order to create a choropleth map clustering and aggregating closer points by averaging some numeric field with Torque in BUILDER:

1-First, create a map with a point dataset. For this example, I am going to use ne_10m_populated_places_simple dataset from CARTO Data Library.

2-Secondly, go to the STYLE tab and select ANIMATED from the Aggregation section.

3-Third, ope the CartoCSS console and apply the following CartoCSS code:

Map {
  -torque-frame-count: 1;
  -torque-animation-duration: 0;
  -torque-time-attribute: "cartodb_id";
  -torque-aggregation-function: "avg(pop_max)";
  -torque-resolution: 12;
  -torque-data-aggregation: cumulative;
}
#layer {
  marker-width: 5;
  marker-fill: #fcde9c;
  marker-fill-opacity: 0.9;
  marker-line-width: 1;
  marker-line-color: #000;
  marker-line-opacity: 1;
}
#layer[value > 50000]{ 
     marker-fill:#faa476;
}
#layer[value > 100000]{ 
     marker-fill:#f0746e;
}
#layer[value > 200000]{ 
     marker-fill:#e34f6f;
}
#layer[value > 300000]{ 
     marker-fill:#dc3977;
}
#layer[value > 400000]{ 
     marker-fill:#b9257a;
}
#layer[value > 500000]{ 
     marker-fill:#7c1d6f;
}

You would only need to change the argument of the torque-aggregation-function and maybe the torque-resolution depending on how your points are spatially distributed. I have also selected a color palette from CARTOcolors.

4-Finally, remove the time series widget that has been automatically generated and add a custom legend. You should end up with a map similar to this one:

https://team.carto.com/u/ramirocartodb/builder/ab797f96-0a40-11e7-a19d-0e3ebc282e83/embed

cluster-torque-choropleth-torque

If you want to know more about the potential of Torque, this old blogpost is the place. :-)

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.