You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: python/mapbox-county-choropleth.md
+31-4
Original file line number
Diff line number
Diff line change
@@ -43,6 +43,33 @@ jupyter:
43
43
To plot on Mapbox maps with Plotly you *may* need a Mapbox account and a public [Mapbox Access Token](https://www.mapbox.com/studio). See our [Mapbox Map Layers](/python/mapbox-layers/) documentation for more information.
44
44
45
45
46
+
Making choropleth maps with `go.Choroplethmapbox` requires two main types of input: GeoJSON-formatted geometry information *where each `feature` has an `id`* and a list of values indexed by feature id. The GeoJSON data is passed to the `geojson` attribute, and the data is passed into the `z` attribute, in the same order as the IDs are passed into the `location` attribute.
47
+
48
+
49
+
#### GeoJSON with `feature.id`
50
+
51
+
Here we load a GeoJSON file containing the geometry information for US counties, where `feature.id` is a [FIPS code](https://en.wikipedia.org/wiki/FIPS_county_code).
52
+
53
+
```python
54
+
from urllib.request import urlopen
55
+
import json
56
+
with urlopen('https://raw.githubusercontent.com/plotly/datasets/master/geojson-counties-fips.json') as response:
57
+
counties = json.load(response)
58
+
59
+
counties["features"][0]
60
+
```
61
+
62
+
#### Data indexed by `id`
63
+
64
+
Here we load unemployment data by county, also indexed by [FIPS code](https://en.wikipedia.org/wiki/FIPS_county_code).
0 commit comments