2
votes

I am attempting to create a choropleth using the actual polygons included in any one of the base Mapbox maps.

Specifically, I have a geojson structure with a data specific property in the properties object and I'd like to have a different color land fill for all countries, depending on where the fall on a certain scale.

So far the Map class appears to color all land at once:

Map { background-color: red; }

And I can't seem to do this:

Map { [myVar > 0.4] { background-color: pink; } [myVar <= 0.4] { background-color: green; } }

I've tried to use my own polygons from my GeoJSON file but they aren't nearly as clean as the Mapbox polygons, even at the highest resolution I've found. Additionally, I want to be able to overlay the labels and other markers that Mapbox base styles have, just on top of my cholorpleth.

I've also tried to color the #admin[admin_level=2][maritime=0] regions, but they don't appear to be polygons and result in something like this:

admin-2 areas fill fail

Thanks in advance!

1
could you do a mockup of what you want the result would look like?mga
could you post a sample of your GeoJSON data?mga
Yes @mga. I am roughly trying to achieve this: i.gyazo.com/b56f3c1cfc55a313b8b3d5bc14151768.png And I put some sample geoJSON here: gist.github.com/iros/e01aa4431e4d30f42ca8 Note the myVar property. It's effectively the same, except I have a few of them and they are more meaningfully named ;). My goal is to generate raster tiles I can use with mapbox.js/leaflet.iros
GeoJSON file does not validate :\mga

1 Answers

3
votes

Assuming Tilemill 0.10.1 and using this GeoJSON (imported as countrydata) and this CartoCSS:

#countrydata {
  line-color:#594;
  line-width:0.5;
  polygon-opacity:1;
  polygon-fill:#ae8;
  [2014_pop>=100000] {polygon-fill:@yellow;}
  [2014_pop>=10000000] {polygon-fill:@orange;}
  [2014_pop>=20000000] {polygon-fill:@pink;}
  [2014_pop>=200000000] {polygon-fill:@red;}
}

I get:

Notice how color is informed by the 2014_pop property. I would recommend naming properties with a starting letter so that the editor doesn't get confused.