Template:Choropleth map
| This template is rated as beta. It is considered ready for widespread use, but as it is still relatively new, it should be applied with some caution to ensure results are as expected. |
| This template uses Lua: |
Use this template to create choropleth maps.
Parameters
[edit]- entities – List of entities to color, separated by semicolons or newlines (example). Can be any country, state, province, municipality, city, etc.[1] Aliases: countries, states, provinces. Entities must be specified by the exact title of their Wikipedia article (redirects don't work) or by their Wikidata identifier (Q123). Countries may also be specified by their two-digit ISO codes (example). Each entity may be preceded by a value followed by a colon (:) that will determine the color of the entity. Colors can be specified by:
- color – Initial color of the colored entities (in hexadecimal). Defaults to red (
#f00). - min-opacity - Minumum opacity of the colored entities. The value must be between 0 and 1 (for example
0.3). Defaults to0. This is useful when coloring entities based on a value or percentage, and the minimum value is too low to be visible (example). - logarithmic-scale - Set this to any value to use a logarithmic scale rather than a linear scale. This is useful when coloring entities based on a value or percentage, and the values span several orders of magnitude (example).
- view – Area where to center the map (examples). Defaults to the world map. Can be any continent, country, state, province, municipality, city, etc.[1] Additionally,
North America,South America,Central AmericaandLatin Americaalso work. Setting this toautowill center around the colored entities (example). - latitude – Latitude where to center the map. If not specified, it will be guessed from the specified view or entities.
- longitude – Longitude where to center the map. If not specified, it will be guessed from the specified view or entities.
- zoom – Level of map detail. Zoom level
0displays the entire available map, and zoom level19shows the highest level of detail. If not specified, a best–guess automatic zoom level is applied based on the selected view or entities. - width – Width of the map in pixels, or
fullto fill the parent container. Defaults to250(the standard width of image thumbnails). - height – Height of the map in pixels. Defaults to
200. - align – Horizontal position of the map on the page. Can be
right,centerorleft. Defaults toright(like image thumbnails). - frameless – Set this to any value to remove the frame around the map. It has no effect if caption or legends are set.
- mapstyle – Style of the basemap. There are currently only two styles available: one with labels (
osm-intl) and one without labels (osm). Defaults toosm-intl. - alt – Alternative text of the map.
- caption – Text below the map.
- legends – Set this to any value to generate automatic legends below the map (examples). If the automatic legends are not good enough, you can omit this parameter and use the caption parameter to build your own legends using Template:Legend.
- source – Source of geographical data in Commons. Defaults to
ChoroplethMap.map, which loads Commons:Data:ChoroplethMap.map. Another example could beFrance Departments.mapwhich would load Commons:Data:France Departments.map (example). When an entity is not found in the data source from Commons, it is fetched from Open Street Map, which works but is slower. This parameter is also useful if you want to show country borders other than the default de facto borders (see #Disputed borders).
Examples
[edit]Basic
[edit]| Markup | Renders as |
|---|---|
{{Choropleth map
| countries = Brazil; Mexico; Egypt; China; Australia
}}
|
Views
[edit]| Markup | Renders as |
|---|---|
{{Choropleth map
| view = South America
| height = 300
| countries = Argentina; Brazil; Chile; Uruguay
}}
|
| Markup | Renders as |
|---|---|
{{Choropleth map
| view = United States
| zoom = 2
| latitude = 45
| longitude = -103
| states = California; Texas; New York (state)
}}
|
| Markup | Renders as |
|---|---|
{{Choropleth map
| view = New York
| entities =
#aaf: Manhattan
#afa: Brooklyn
#faa: Queens
#aff: The Bronx
#faf: Staten Island
}}
|
ISO codes
[edit]| Markup | Renders as |
|---|---|
{{Choropleth map
| color = #aaf
| countries = CN; US; DE; BR; AU; EG
}}
|
Color groups
[edit]| Markup | Renders as |
|---|---|
{{Choropleth map
| countries =
#faa: Mexico; United States; Brazil
#aaf: Italy; Spain; France; Germany
#afa: China; India
#faf: Australia
}}
|
Color by percentage
[edit]| Markup | Renders as |
|---|---|
{{Choropleth map
| height = 250
| view = North America
| countries =
80%: United States
60%: Canada
40%: Mexico
}}
|
Color by value
[edit]| Markup | Renders as |
|---|---|
{{Choropleth map
| view = South America
| height = 300
| color = #00f
| countries =
400: BR
300: UY; CL; PE
200: AR; PY
100: BO; CO; VE; EC
#aff: SR; GY; GF
}}
|
Automatic legends
[edit]| Markup | Renders as |
|---|---|
{{Choropleth map
| legends = yes
| view = South America
| height = 300
| countries =
70%: Uruguay
60%: Brazil
50%: Chile; Argentina; Ecuador
40%: Peru; Paraguay; Bolivia
30%: Colombia; Venezuela
#aff: Guyana; Suriname; French Guiana
}}
|
| Markup | Renders as |
|---|---|
{{Choropleth map
| caption = GDP per capita (in thousands of USD):
| legends = yes
| height = 250
| view = North America
| countries =
94.4: United States
60.3: Canada
15.7: Mexico
}}
|
Low values and wide ranges
[edit]| Markup | Renders as |
|---|---|
{{Choropleth map
| view = auto
| zoom = 2
| height = 250
| min-opacity = 0.1
| logarithmic-scale = yes
| caption = Population (in millions):
| legends = yes
| countries =
1470: India
1404: China
285.7: Indonesia
122.5: Japan
116.8: Philippines
101.6: Vietnam
71.6: Thailand
54.9: Myanmar
51.6: South Korea
36.0: Malaysia
29.6: Nepal
23.0: Taiwan
17.8: Cambodia
7.9: Laos
5.9: Singapore
1.4: Timor-Leste
0.5: Brunei
}}
|
Alternative source
[edit]| Markup | Renders as |
|---|---|
{{Choropleth map
| source = France Departments.map
| entities = Finistère; Nord (French department); Bas-Rhin; Var (department); Pyrénées-Atlantiques; Indre
}}
|
Disputed borders
[edit]By default, this template uses country data from Commons:Data:ChoroplethMap.map, which aims to reflect de facto borders. If you want to display different borders, you can create a new map page on Commons by copy-pasting ChoroplethMap.map, modifying the borders (https://geojson.io is a useful tool for that), and then loading the modified data using the "source" parameter of this template.
Template data
[edit]Use this template to create choropleth maps.
| Parameter | Description | Type | Status | |
|---|---|---|---|---|
| Entities | entities countries states provinces | List of entities to color, separated by semicolons or newlines.
| String | suggested |
| Color | color | Initial color of the colored entities (in hexadecimal).
| String | optional |
| View | view | Area where to center the map.
| String | optional |
| Latitude | latitude | Latitude where to center the map.
| Number | optional |
| Longitude | longitude | Longitude where to center the map.
| Number | optional |
| Zoom | zoom | Level of map detail.
| Number | optional |
| Width | width | Width of the map in pixels, or "full" to fill the parent container.
| Number | optional |
| Height | height | Height of the map in pixels.
| Number | optional |
| Align | align | Horizontal position of the map on the page.
| String | optional |
| Frameless | frameless | Set this to any value to remove the frame around the map.
| Boolean | optional |
| Map style | mapstyle | Style of the basemap.
| String | optional |
| Alternative text | alt | Alternative text of the map. | String | optional |
| Caption | caption | Text below the map. | String | optional |
| Legends | legends | Set this to any value to generate automatic legends below the map.
| Boolean | optional |
| Source | source | Source of geographical data in Commons.
| String | optional |
Notes
[edit]- 1 2 Technically, any entity that has an area defined in Open Street Map and is linked to a Wikidata entity.











