see if this may help.
The idea is:
- To identify microstates by area. So you may need to compute the area of each country and add that as an additional variable. Based on a thresold (in my example, it is set to 1900000000 (m^2)
- Split your dataset based on micro vs non-micro states.
- For those countries identified as micro states, replace the shape for a polygon that is the centroid of the country buffered by a given distance (in my case 200 kms). This would determine the final size of the circle for each microstate
- Recreate the initial dataset with the non-micro states plus the modified microstates.
See how this can be done. You may want to play with the thresold for identifying microstates and the distance of the buffer.
library(giscoR)
library(ggplot2)
library(dplyr)
#>
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#>
#> filter, lag
#> The following objects are masked from 'package:base':
#>
#> intersect, setdiff, setequal, union
library(sf)
#> Linking to GEOS 3.9.1, GDAL 3.4.3, PROJ 7.2.1; sf_use_s2() is TRUE
cnt <- gisco_get_countries() %>%
st_transform("+proj=robin")
mapborder <- st_bbox(gisco_get_countries(epsg = 4326)) %>%
st_as_sfc() %>%
st_segmentize(1000000) %>%
st_transform(st_crs(cnt)) %>%
st_cast("LINESTRING")
# Mock variable for plotting choropleth
cnt$mock <- sample(letters[1:4], size = nrow(cnt), replace = TRUE)
# Area of countries
cnt$area <- as.double(st_area(cnt))
cnt <- cnt %>% arrange(desc(area))
# Thresold for determining which countries are tiny (in terms of area)
thr <- 1900000000
notiny <- cnt %>% filter(area >= thr)
# Make tiny circles
tiny <- cnt %>%
filter(area < thr) %>%
mutate(tiny = TRUE) %>%
# Create a circle with a buffer of 200 kms
st_centroid(of_largest_polygon = TRUE) %>%
st_buffer(200000)
#> Warning in st_centroid.sf(., of_largest_polygon = TRUE): st_centroid assumes
#> attributes are constant over geometries of x
all <- notiny %>% bind_rows(tiny)
ggplot(all) +
geom_sf(data = mapborder, size = 0.1) +
geom_sf(aes(fill = mock), color = NA) +
theme_void()
Created on 2022-08-23 with reprex v2.0.2