Function Repository Resource:

NoncontiguousCartogram

Source Notebook

Create a noncontiguous cartogram

Contributed by: Björn Zimmermann

ResourceFunction["NoncontiguousCartogram"][locval]

displays location loc with area scaled according to val.

ResourceFunction["NoncontiguousCartogram"][{loc1val1,loc2val2,}]

displays the loci with areas scaled according to the vali.

Details and Options

ResourceFunction["NoncontiguousCartogram"] returns Graphics.
The locations loc can be 2D shapes, in which case they are scaled around their individual centroids.
The locations loc can be coordinate pairs, a GeoPosition, or Entity or EntityClass objects with geographic coordinates, such as cities or countries.
Numerical values associated to locations can be given either explicitly or, for Entity or EntityClass locations, given as a Property.
The values are used to derive a suitable overall scale.
The original shapes are scaled according to val based on area, while maintaining both their shape and center. Topology is not preserved.
Location value pairs in Association are supported.

Examples

Basic Examples (2) 

Make a noncontiguous cartogram with squares:

In[1]:=
ResourceFunction["NoncontiguousCartogram"][{
  Polygon[{{-10, 0}, {-10, 10}, {0, 10}, {0, 0}}] -> 1,
  Polygon[{{0, -10}, {0, 0}, {10, 0}, {10, -10}}] -> 0.5,
  Polygon[{{0, 0}, {0, 10}, {10, 10}, {10, 0}}] -> 0.75,
  Polygon[{{-10, -10}, {-10, 0}, {0, 0}, {0, -10}}] -> 0.25}]
Out[1]=

Create a noncontiguous cartogram of the countries of the East African Community (EAC) by their Gross Domestic Product (GDP):

In[2]:=
ResourceFunction["NoncontiguousCartogram"][
 EntityClass["Country", "EastAfricanCommunity"] -> "GDP"]
Out[2]=

Scope (4) 

Create a noncontiguous cartogram of US states based on the fraction of their population not born in the US:

In[3]:=
USstates = Complement[
   EntityList[
    Entity["AdministrativeDivision", {EntityProperty[
        "AdministrativeDivision", "ParentRegion"] -> Entity["Country", "UnitedStates"]}]], {Entity[
     "AdministrativeDivision", {"Alaska", "UnitedStates"}], Entity["AdministrativeDivision", {"Hawaii", "UnitedStates"}]}];

Use automatic arrangement:

In[4]:=
ResourceFunction["NoncontiguousCartogram"][
 USstates -> EntityProperty["AdministrativeDivision", "ForeignBornFraction"]]
Out[4]=

Use a List of rules of GeoPosition polygons with their respective values:

In[5]:=
ResourceFunction["NoncontiguousCartogram"][
 Thread[Rule[EntityValue[USstates, "Polygon"], EntityValue[USstates, EntityProperty["AdministrativeDivision", "ForeignBornFraction"]]]]]
Out[5]=

Use an Association of rules of GeoPosition polygons with their respective values:

In[6]:=
ResourceFunction["NoncontiguousCartogram"][
 Association @@ Thread[Rule[EntityValue[USstates, "Polygon"], EntityValue[USstates, EntityProperty["AdministrativeDivision", "ForeignBornFraction"]]]]]
Out[6]=

Version History

  • 1.0.0 – 23 September 2020

Related Resources

License Information