0
votes

I have played with Mapbox and can quite easily create a Choropleth map in Mapbox studio and interact with it in Javascript.

I would like to create Choropleth map of the states with the ability to change the colours of the states for 100 years of different data points. I'm not allowed to upload the data into Mapbox as its sensitive healthcare data and I can't get sign of for the $499 a month cost.

My idea is I create a mapbox style layer in MapBox Studio then push the data client side for each of the states depending on the year x that the user selects. I have seen quite a few cloropeth tutorials such as this https://www.mapbox.com/help/choropleth-studio-gl-pt-1/ but the data is added in through a layer in Mapbox Studio. My thoughts are to embed the large GeoJson in the style and only push the data to the Polygon ID's, whilst creating transtions between the two.

Does anyone have any ideas if this is possible? and perhaps any useful API requests which may help me achieve this https://www.mapbox.com/api-documentation/.

1

1 Answers

0
votes

It's possible. There are two approaches:

  1. Upload the geometry as a Dataset in Studio, or load it directly as a GeoJSON.
  2. Set data attributes directly on the geometry.
  3. Create a style with data-driven styles (eg, map "47" to "rgb(100,0,0)" and "153" to "rgb(250,250,0)" and let Mapbox interpolate.

Or:

  1. Upload the geometry as a Tileset to Studio.
  2. Calculate the color you want to represent each possible value of each state.
  3. Generate a data-driven style property that maps each state's code to the color you want, like ...['FL','rgb(143,15,0)']....

Neither method will cope with large numbers of regions, but should be ok for 50 US states at low resolution.

More discussion here: https://github.com/mapbox/mapbox-gl-js/issues/4261