A cartogram is a map in which the geometry of regions is distorted in order to convey the information of an alternate variable. In this post, we are going to draw a map of Africa where the size of each country is distorted proportionally to its population. A cartogram is frequently a choropleth map in which regions are colored according to a numeric value (not necessarily the one used to build the cartogram). To understand the cartogram more easily, one can refer to what a geospatial object is.
Preparing the Map data and creating Basic Cartogram
To perform a cartogram map we will create map data using wrld_simpl.
afr = wrld_simpl[wrld_simpl$REGION==2,]
Spatial Polygon Features in Cartogram
We have a spatial object and a numeric value associated with each region, it is possible to color each region according to its value.
Cartogram and its customization
Here we will create cartogram and then we will customize for this we will use wrld_simpl and then extract the information like shape, coordinates and then transform geometry polygon objects to new geospatial objects.
afr_data = wrld_simpl[wrld_simpl$REGION == 2,]
"Type of afr_data: "
(sfno, crs = 23038)
, itermax = 7)
(data = afr_cartogram,
(fill = POP2005))
Type of afr_data: S4
Mean size error for iteration 1: 6.65362274402649
Mean size error for iteration 2: 5.77932593731838
Mean size error for iteration 3: 5.11349284302375
Mean size error for iteration 4: 4.56333360251358
Mean size error for iteration 5: 4.09786807153034
Mean size error for iteration 6: 3.69769020137334
Mean size error for iteration 7: 3.3519304681889
Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses
are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!