Another issue with using GDAM for global maps, other than having to make a collection from individual countries, is that the country polygons have a too high resolution. Itโs simpler to use a low resolution dataset, like for example https://github.com/datasets/geo-countries/blob/master/data/countries.geojson
I have updated the GMT.jl choropleth examples where one does something very similar to what the OP seems to want. Adapting this example to the Mean salary data should be straightforward.
Using GMT, CSV, HTTP, DataFrames
# Read the country polygons directly into a GMTdadset
countries = gmtread("/vsicurl/https://github.com/datasets/geo-countries/raw/master/data/countries.geojson");
# Read a file with the population density into a DataFrame
pop = CSV.File(HTTP.get(https://raw.githubusercontent.com/tillnagel/unfolding/master/data/data/countries-population-density.csv).body, delim=';') |> DataFrame;
Both the countries
and pop
share a common attribute, the Country code
julia> countries
Vector{GMTdataset} with 4264 segments
Show first segment. To see other segments just type its element number. E.g. D[7]
Attributes: Dict("ISO_A2" => "AW", "ISO_A3" => "ABW", "ADMIN" => "Aruba")
BoundingBox: [-70.06240800699987, -69.87682044199994, 12.417669989000046, 12.632147528000104]
PROJ: +proj=longlat +datum=WGS84 +no_defs
and
julia> pop
248ร3 DataFrame
Row โ Country Name Country Code 2010
โ String String3 Float64?
โโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
1 โ Arab World ARB 26.2725
2 โ Caribbean small states CSS 16.9939
3 โ East Asia & Pacific (all income โฆ EAS 90.5122
4 โ East Asia & Pacific (developing โฆ EAP 123.729
Now create a numeric vector linking the population density and the country polygons via the attribute โISO_A3โ
zvals = polygonlevels(countries, string.(pop[!,2]), pop[!,3], att="ISO_A3");
and use it to create the colors in the map.
# First create the colormap. Limit the maximum range to 500 otherwise states
# like Monaco would the all the `reds` and the rest of the world would be all blues.
C = makecpt(range=(0,500,10));
plot(countries, region=(-180,180,-60,85), level=zvals, cmap=C, proj=:guess,
title="World population density", colorbar=true, show=true)