Drawing points in a map with GMT

Dear all,
I have the code below where I plot south america with GMT:

using GMT
# Desenhe o mapa
coast(region=(-90, -30, -60, 15), proj=:Mercator, xaxis=(annot=10,ticks=5), yaxis=(annot=10,ticks=5), area=:10, land=:brown, scale=0.05, title="Capitais da América do Sul", show=true)

works well. I would like to insert, for example, the capitals in this map: for example:

# Defina as coordenadas das capitais da América do Sul
capitais = [
    ("Bogotá", -74.08, 4.61),  # Colômbia
    ("Quito", -78.50, -0.22),  # Equador
    ("Lima", -77.03, -12.05),  # Peru
    ("Santiago", -70.67, -33.45),  # Chile
    ("Buenos Aires", -58.38, -34.60),  # Argentina
    ("Montevideo", -56.17, -34.85),  # Uruguai
    ("Brasília", -47.93, -15.78),  # Brasil
    ("Caracas", -66.90, 10.48),  # Venezuela
    ("Georgetown", -58.15, 6.80),  # Guiana
    ("Paramaribo", -55.17, 5.83),  # Suriname
    ("Cayenne", -52.33, 4.93)  # Guiana Francesa
]

When I trun the code below I have an error:

# Adicione as capitais ao mapa
for capital in capitais
    nome, lon, lat = capital
    plot!(lon, lat, marker=:circle, markersize=0.5, markerfacecolor=:red, markeredgecolor=:black)
    annotate!(lon, lat, text=nome, textcolor=:black, fontsize=10)
end

How can I insert a given set of points in this map?

You cannot use show=true in first plot command because it will end the figure. show is only used in lat command when we finished. Also, annotate! function does not exist (yet) in GMT. Checking the text man page helps.

One way of doing that

nomes = ["Bogotá", "Quito", "Lima", "Santiago", "Buenos Aires", "Montevideo", "Brasília", "Caracas", "Georgetown", "Paramaribo", "Cayenne"];
pts = [-74.08 4.61
		-78.50 -0.22
		-77.03 -12.05
		-70.67 -33.45
		-58.38 -34.60
		-56.17 -34.85
		-47.93 -15.78
		-66.90 10.48
		-58.15 6.80
		-55.17 5.83
		-52.33 4.93];

D = mat2ds(pts, nomes);

coast(region=(-90, -30, -60, 15), proj=:Mercator, xaxis=(annot=10,ticks=5), yaxis=(annot=10,ticks=5), area=:10, land=:brown, title="Capitais da América do Sul")

plot!(D, marker=:circle, markersize=0.5, markerfacecolor=:red, markeredgecolor=:black)
text!(D, show=true)

Thank you so much! Wonderfulll.
One more question: if I want to connect the cities of Santiago to Brasil, Santiago to Bogotá, etc… (with an arrow), how can I do this?

… and reduce the font size of the capitals. Thank you so much!

There is the connection option of the plot function, but it is a bit daunting. At least without concrete examples. Maybe what’s in this example is simpler.

See the text manual I pointed above.

1 Like