Wolfram Research

Function Repository Resource:

Cartogram

Source Notebook

The cartogram function generates geometrically distorted maps, where the distortion conveys information derived from the input data.

Contributed by: Richard Lapin

ResourceFunction["Cartogram"][reg]

generates a plot of width 100 in which geographic region reg specified in the form of an Entity object are displayed after 30 iterations; the destortion is based on equalising the population densities by default.

ResourceFunction["Cartogram"][{reg1 val1, reg2 val2,}]

generates a plot in which geographic regions reg1 and reg2 specified in the form of Entity objects are displayed after 30 iterations, where the distortion is based on the values val1 and val2.

ResourceFunction["Cartogram"][reg,iterations]

generates a plot in which geographic region reg is displayed after the specified number of iterations.

ResourceFunction["Cartogram"][reg,iterations,res]

generates a plot of width res.

ResourceFunction["Cartogram"][reg,iterations,res,plotAll]

generates a list of plots of width res from the undistorted map to the specified number of iterations.

Details and Options

The reg can be Entity objects such as countries corresponding to extended geographic regions, or geometric constructs with GeoPosition coordinates.
The val is a number.

Examples

Basic Examples

A list of different examples:

In[1]:=
ResourceFunction["Cartogram"][EntityClass["Country", "CentralEurope"]]
Out[1]=

Running the function for a list of countries:

In[2]:=
ResourceFunction[
 "Cartogram"][{Entity["Country", "Germany"], Entity["Country", "Poland"], Entity["Country", "France"]}]
Out[2]=

Running the function for a list of countries using the user-input values:

In[3]:=
ResourceFunction[
 "Cartogram"][{Entity["Country", "Germany"] -> 100, Entity["Country", "Poland"] -> 101, Entity["Country", "France"] -> 150}]
Out[3]=

Running the function for just one iteration:

In[4]:=
ResourceFunction[
 "Cartogram"][{Entity["Country", "Germany"] -> 100, Entity["Country", "Poland"] -> 101, Entity["Country", "France"] -> 150}, 1]
Out[4]=

Running the function for 5 iterations with the width of 400 pixels.

In[5]:=
ResourceFunction[
 "Cartogram"][{Entity["Country", "Germany"] -> 100, Entity["Country", "Poland"] -> 101, Entity["Country", "France"] -> 150}, 5, 400]
Out[5]=

Returns all steps of first 5 iterations:

In[6]:=
ResourceFunction[
 "Cartogram"][{Entity["Country", "Germany"] -> 100, Entity["Country", "Poland"] -> 101, Entity["Country", "France"] -> 101}, 5, 200, True]
Out[6]=

Resource History

Source Metadata

Author Notes

High resolution iterations are computationally intensive and take a long time. For instance, 500 iterations of contiguous US states at resolution of 1000 took around 3 hours (link for the output below): https://youtu.be/ggcOGzDh1qo

License Information