Projection errors

Hi PyGMT experts,

Thank you for making PyGMT, and for the great efforts in updating and improving the packages. It is very much appreciated.

I have two issues. Do I need to make two different topics?

I am using


The first issue:

This may be a bug. I a trying to make a polar sterographic plot of Antarctica, but it is only working when I use projection -Js and not -JS (using ordinary GMT notation). Here, is an example:

grid = pygmt.datasets.load_earth_relief(resolution="05m", region=[-180,180,-90,-40])
fig = pygmt.Figure()
fig.basemap(region="-130/-50/45/-50r", projection="S0/-90/-70/8c", frame="a20f20")

I get this error:

basemap [ERROR]: Option -J parsing failure. Correct syntax:
-Js<lon0>/<lat0>[/<horizon>]/<scale> OR -JS<lon0>/<lat0>[/<horizon>]/<width>
<horizon> is distance from center to perimeter (< 180, default 90)
<scale> is <1:xxxx>, <lat>/<1:xxxx>, or <radius> (in cm)/<lat>, or use <width> in cm
basemap [ERROR]: Offending option -JS0/-90/-70/8c
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/g5/procdata/skr/anaconda3/envs/pygmt4/lib/python3.9/site-packages/pygmt/helpers/", line 586, in new_module
    return module_func(*args, **kwargs)
  File "/g5/procdata/skr/anaconda3/envs/pygmt4/lib/python3.9/site-packages/pygmt/helpers/", line 726, in new_module
    return module_func(*args, **kwargs)
  File "/g5/procdata/skr/anaconda3/envs/pygmt4/lib/python3.9/site-packages/pygmt/src/", line 84, in basemap
    lib.call_module("basemap", build_arg_string(kwargs))
  File "/g5/procdata/skr/anaconda3/envs/pygmt4/lib/python3.9/site-packages/pygmt/clib/", line 500, in call_module
    raise GMTCLibError(
pygmt.exceptions.GMTCLibError: Module 'basemap' failed with status code 72:
basemap [ERROR]: Option -J parsing failure. Correct syntax:
basemap [ERROR]: Offending option -JS0/-90/-70/8c

This works with no problems:

 grid = pygmt.datasets.load_earth_relief(resolution="05m", region=[-180,180,-90,-40])
 fig = pygmt.Figure()
 fig.basemap(region="-130/-50/45/-50r", projection="s0/-90/-70/1:5000000", frame="a20f20")
 fig.grdimage(grid=grid, cmap="gray")
 fig.savefig('test.png', show=True)

Am I doing something wrong? I have tried to plot the same thing with a northern polar stereographic projection (projection="S-45/90/70/8c), but with no issues. I can live with using the “Js” solution, but I just find it strange,

Second issue

I would like to plot projected data on top of an earth relief grid. How do I do this? Do I need to reproject the earth relief data first? I have used this example (42) Antarctica and stereographic data — GMT 6.5.0 documentation to plot fx. coastlines in geographical coordinates on top of my projected data. This works, but when I start by using the geographical coordinates (fx. plotting earth relief as a background) with my projected data on top it goes wrong:

# grid_relief = pygmt.datasets.load_earth_relief(resolution="05m", region=[-180, 180, -90, -40)

region = "-130/-52/45/-50r"
fig = pygmt.Figure()
# fig.grdimage(grid=grid_relief, region=regionr, cmap="gray", projection="s0/-90/-70/1:50000000") ## Wanted to make a background map
pygmt.makecpt(cmap="devon", series=[0,100])
fig.grdimage(grid=ds, cmap=True, projection="x1:50000000") ## My projected data (
fig.basemap(region=region, projection="s0/-90/-70/1:50000000", frame=[frame[0], frame[1], f'+t"{title}"'])
fig.coast(shorelines="0.5p,black",  projection=""s0/-90/-70/1:50000000, frame=['WSEn', frame[0], frame[1]])

I have uncommented the lines that do not work! My workaround right now is to reproject my input data through Pythons pyproj, but I guess it is possible in pyGMT to plot it without the reprojection.!

Below I have attached two figures. The first shows my projected data (satellite tracks) without the background relief and the second figure show the background image, but no projected data.

I have also played around with grdproject, but this does not give me any valied values:

ds_proj = pygmt.grdproject(grid=ds, projection="s0/-90/-70/1:50000000", region=regionr, inverse=True)

About the first issue, I think that the horizon parameter of -JS should be a positive number even if you are working on the south pole. Maybe you could try using:


Hi @Sistjerne! Yeah, as @Esteban82 mentioned, the projection information might need to be a positive number for some reason, I felt like this was a bug introduced sometime around GMT 6.1 or 6.2…

As for your 2nd problem, instead of the earth_relief grid (SRTM based), I recommend using the Reference Elevation Model of Antarctica (REMA) since it is already in the Antarctic Stereographic Projection (EPSG:3031), so no need to reproject (plus the earth_relief grid uses REMA as the source anyway). You can then overlay your projected data on top easily. Get it at:

E.g. use pygmt.which("", download=True) to download the GeoTIFF file.

Tip: If you want to plot the Antarctic grounding line, you could try:

    region="REMA_200m_dem_filled.tif",  # or specify in EPSG:3031 coordinates [minx, maxx, miny, maxy]
    # frame="ag",

P.S. I have some code from a poster this year at and nzasc2021/ at 15851c3ea797ae2cccf7b10f3d08f498a5314d3e · weiji14/nzasc2021 · GitHub that might be helpful


P.P.S. I have some older code (using PyGMTv0.1/GMT 6.0) that may be helpful at deepbedmap/ at 0e766fb5789700e63ac38029bd5a0499838431a5 · weiji14/deepbedmap · GitHub and

There is no option to select map width (-JS) and also specify a specific latitude and radius (-70/8c). That can only be done when you specify a scale (-Js).

I have added a bit more checking in master which would give an error for your failing command. I also improved parsing a bit and updated the docs to be clearer on a few items related to -Js|S.

Thank you very much for the thorough answers. I have fixed all my issues!

I can use the projection:


@weiji14 I really appreciate all your examples. I have indeed learned a lot new about pyGMT by looking at them!

1 Like