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: announcement.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,7 +20,7 @@ Check out the image below to see how much nicer this makes everything look.
20
20
21
21
#### GeoJson Choropleth Maps and Mapping Improvements
22
22
23
-
Choropleth maps now accept a `geojson` argument. This means that you can now supply your own geometry information to non-tile-map choropleth maps, instead of relying on Plotly’s built-in country and state maps. Some other new mapping features include:
23
+
Choropleth maps now accept a [`geojson`](https://plotly.com/r/mapbox-county-choropleth/#choropleth-map-with-geojson) argument. This means that you can now supply your own geometry information to non-tile-map choropleth maps, instead of relying on Plotly’s built-in country and state maps. Some other new mapping features include:
24
24
25
25
- New [`featureidkey`](https://plotly.com/r/mapbox-county-choropleth/#geojson-with-featureid) attribute to let you use GeoJSON objects whose identifiers are in the properties object of a feature, rather than always and only using the `id` field. (This was added to the Mapbox choropleth trace as well.)
A [Choropleth Map](https://en.wikipedia.org/wiki/Choropleth_map) is a map composed of colored polygons. It is used to represent spatial variations of a quantity. This page documents how to build **outline** choropleth maps, but you can also build [choropleth **tile maps** using our Mapbox trace types](/r/mapbox-county-choropleth).
22
+
23
+
### Base Map Configuration
24
+
25
+
Plotly figures made with `plot_geo` have a `layout.geo` object which can be used to control the appearance of the base map onto which data is plotted.
26
+
27
+
### Introduction: main parameters for choropleth outline maps
28
+
29
+
Making choropleth maps requires two main types of input:
30
+
31
+
1. Geometry information:
32
+
1. This can either be a supplied GeoJSON file where each feature has either an `id` field or some identifying value in `properties`; or
33
+
2. one of the built-in geometries within `plot_geo`: US states and world countries (see below)
34
+
2. A list of values indexed by feature identifier.
35
+
36
+
The GeoJSON data is passed to the `geojson` argument, and the data is passed into the `z` argument of `plot_geo`.
37
+
38
+
**Note** the `geojson` attribute can also be the URL to a GeoJSON file, which can speed up map rendering in certain cases.
39
+
40
+
### GeoJSON with `feature.id`
41
+
42
+
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).
43
+
44
+
```{r}
45
+
library(plotly)
46
+
library(rjson)
47
+
48
+
data <- fromJSON(file="https://raw.githubusercontent.com/plotly/datasets/master/geojson-counties-fips.json")
49
+
data$features[[1]]
50
+
```
51
+
52
+
#### Data indexed by `id`
53
+
54
+
Here we load unemployment data by county, also indexed by [FIPS code](https://en.wikipedia.org/wiki/FIPS_county_code).
**Note** In this example we set `layout.geo.scope` to `usa` to automatically configure the map to display USA-centric data in an appropriate projection.
Copy file name to clipboardExpand all lines: r/2020-01-30-choropleth-rmapbox.Rmd
+2-2Lines changed: 2 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -3,7 +3,7 @@ description: How to make a Mapbox Choropleth Map of US Counties in R with Plotly
3
3
display_as: maps
4
4
language: r
5
5
layout: base
6
-
name: Choropleth mapbox
6
+
name: Mapbox Choropleth Maps
7
7
order: 8
8
8
output:
9
9
html_document:
@@ -33,7 +33,7 @@ Making choropleth Mapbox maps requires two main types of input:
33
33
1. GeoJSON-formatted geometry information where each feature has either an `id` field or some identifying value in `properties`.
34
34
2. A list of values indexed by feature identifier.
35
35
36
-
The GeoJSON data is passed to the `geojson` argument, and the data is passed into the `color` argument of `px.choropleth_mapbox` (`z` if using `graph_objects`), in the same order as the IDs are passed into the `location` argument.
36
+
The GeoJSON data is passed to the `geojson` argument, and the data is passed into the `z` argument of `plot_geo`.
37
37
38
38
**Note** the `geojson` attribute can also be the URL to a GeoJSON file, which can speed up map rendering in certain cases.
0 commit comments