Using open data from the United States Department of Agriculture’s Food Access Research Atlas to map the percent of people in each county in the United States with low access to healthy food as defined by the USDA. Ideally, the counties with the highest percentages of people without access to food stand out from the rest regardless of other parameters like county size, population, etc.
A choropleth map (left) and scaled dots (right) depicting USDA food access data
In addition to joining the tabular data to the geometry, the query performs the following cartographic functions:
Order the records by PCT_LACCESS_POP10 so that larger values are at the top of table. This means Mapnik will draw them first, in favor of smaller values.
Improve legibility by creating a new column pct_access that rounds percentages to one decimal place and concatenates a percentage sign.
Display ‘n/a’ where a county has a null value for PCT_LACCESS_POP10 rather than leave an empty space.
Perform a left join against the county geometry so that we do not have blank areas on the map where there should be counties.
CartoCSS for every zoom level
With CartoCSS, you can quickly make sure that these scales look good at every zoom level and maintain their relative proportions - crucial for effectively communicating your data data to users. Using CSS-style variables and some simple math, we can quickly scale six data classes that determine the size of each number across zoom levels.
Note that TileMill needs the numeric column pct_laccess_pop10 to classify the values, but we are feeding the string column pct_access to the text-name symbolizer to display the more legible rounded values with percent signs.
With our textual heat map layer rendered and uploaded to MapBox hosting, all that’s left is to add a custom MapBox layer as a base map and publish. It’s now easier than ever to sign up and start publishing your data-driven maps with MapBox.