GMT plotting problem with geographic coordinates

Hi everyone, I am experiencing a strange problem when plotting a small area with GMT using the Mercator projection (-JM).

The region I specify is:

-R38.7497222222/38.7661111111/9.00805555556/9.02444444444

However, the resulting plot appears to show the latitude range as approximately:

9.08 – 9.24

It looks as if GMT is somehow dropping the 0 immediately after the decimal point (i.e., 9.008 is being interpreted/displayed as 9.08).

I have checked the grid metadata, and the grid itself has the correct limits:

x_min: 38.7497222222
x_max: 38.7661111111
y_min: 9.00805555556
y_max: 9.02444444444

I also tested the plot outside of my subplot script, using the region and projection directly, and the same problem occurs.

The GMT debug output also confirms that GMT is receiving the correct -R values:

Got regular w/e/s/n for region

(38.7497222222/38.7661111111/9.00805555556/9.02444444444)

Has anyone encountered a similar problem, or have an idea what could cause GMT to plot/interpret the latitude range this way? Any suggestions would be greatly appreciated.

Hello @Elmas.

Could you share a simplified script that shows this behaviour?

Hey @Elmas,

Thanks for this detailed report. I just had a quick look at this as it remains me on an issue in GMT 6.6.0, please see Wrong annotation and gridline positions for rounded values · Issue #8490 · GenericMappingTools/gmt · GitHub. This was fixed in GMT 6.7.0. Regarding your issue I played around with FORMAT_GEO_MAP (using PyGMT with GMT 6.7.0) and found this:

import pygmt

# R38.7497222222/38.7661111111/9.00805555556/9.02444444444
region = [38.7497222222, 38.7661111111, 9.00805555556, 9.02444444444]

fig = pygmt.Figure()

with pygmt.config(FORMAT_GEO_MAP="ddd.xF"):
    fig.basemap(region=region, projection="M5c", frame="a0.0001")

fig.shift_origin(xshift="+w+2c")

with pygmt.config(FORMAT_GEO_MAP="ddd.xxF"):
    fig.basemap(region=region, projection="M5c", frame="a0.0001")

fig.shift_origin(xshift="+w+2c")

with pygmt.config(FORMAT_GEO_MAP="ddd.xxxF"):
    fig.basemap(region=region, projection="M5c", frame="a0.0001")

fig.shift_origin(xshift="+w+2c")

with pygmt.config(FORMAT_GEO_MAP="ddd.xxxxF"):
    fig.basemap(region=region, projection="M5c", frame="a0.0001")

fig.shift_origin(xshift="+w+2c")

with pygmt.config(FORMAT_GEO_MAP="ddd.xxxxxF"):
    fig.basemap(region=region, projection="M5c", frame="a0.0001")

fig.show()

For FORMAT_GEO_MAP="ddd.xxxF" (third panel), the y-annotations are wrong, as the zero directly after the comma is skipped and still only two digits after the comma are shown. When using FORMAT_GEO_MAP="ddd.xxxxF" (fourth panel), the y-annotations are correct, i.e., this zero is there and four digits after the comma are shown as expected.

How do you get this latitude range? Reading off the map?

its not 9.08 – 9.24, its 9.00805555556/9.02444444444
apparently its 9:00:29/9:01:28 converted to decimal degrees.
This notation, DDD:MM:SS, can be used instead if degrees-minutes-seconds is needed.

Thanks to all,

As Yvonne suggested, using “gmt set FORMAT_GEO_MAP ddd.xxxxF” resolves the issue, and everything is now being plotted correctly. It appears that the problem is related to GMT 6.6.0.

Update:** I have now upgraded to GMT 6.7.0 and tested the same case. Unfortunately, the problem still persists in GMT 6.7.0. The specified region is correctly read as -R38.7497222222/38.7661111111/9.00805555556/9.02444444444, but the latitude annotations are still displayed incorrectly.

I also tested with FORMAT_GEO_MAP=ddd.xxxxF, which gives the right coordinate, but without it the issue itself is still present.

Interestingly, the same GMT commands and projection work properly for other geographic regions. The problem appears to be specific to this particular region around 9° latitude. Thus, upgrading from GMT 6.6.0 to 6.7.0 does not resolve the issue in this case.

In GMT 6.7.0, the problem reported at issue 8490 in the GMT repo is fixed.

The issue reported here, is a separat bug and occurs also with GMT 6.7.0. I opened an issue in the GMT repo. And there is already a PR aiming to fix this.

Thank you very much for identifying and fixing this issue. I understand that PR #9155 has already been merged.

May I ask whether this fix is expected to be included in the next stable GMT release? If so, is there an approximate timeframe for that release? I am currently using FORMAT_GEO_MAP=ddd.xxxxF as a workaround, but the four-decimal annotations are quite long and can extend around the frame of my figures. I would therefore be interested to know when I can expect the corrected behavior to be available in an official release.
Thank you again