2

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!

iros
  • 1,055
  • 1
  • 7
  • 8
  • could you do a mockup of what you want the result would look like? – mga Aug 27 '15 at 19:14
  • could you post a sample of your GeoJSON data? – mga Aug 27 '15 at 19:20
  • Yes @mga. I am roughly trying to achieve this: https://i.gyazo.com/b56f3c1cfc55a313b8b3d5bc14151768.png And I put some sample geoJSON here: https://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 Aug 27 '15 at 19:32
  • GeoJSON file does not validate :\ – mga Aug 27 '15 at 19:39

1 Answers1

3

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.

mga
  • 1,960
  • 1
  • 23
  • 31
  • So, not quite. Yes, I can use that GeoJSON to render the polygons in it, but they aren't as high resolution: https://i.gyazo.com/ae56ca107a19280c6247ac4177509285.png I would basically have to try and replicate the layout and data using my own GeoJSON. – iros Aug 27 '15 at 20:35
  • This was a response I got so far: https://twitter.com/chieflybrit/status/636987450460475392 – iros Aug 27 '15 at 20:37
  • 1
    when you create a new map on TileMill with "default data" you get a base with high res polygons. you can download that dataset from [Natural Earth](http://www.naturalearthdata.com/downloads/10m-cultural-vectors/) and add whatever attributes you need for your map – mga Aug 27 '15 at 20:50
  • It looks like that's the best option I have @mga. Thanks so much for looking into it. – iros Aug 27 '15 at 20:54