Grdgradient in pygmt

My current objective is to make a map of nothern Tanzania that shows the main structures (volcanoes and faults). I tried to use the example four from the gmt website but I get an error with the .gdrgradient module.

Do I need to install some library? Or is there another module ?
Thank you !

Please, post the errors as text. Not as screen-captures.

Noted. Here’s my code:

fig.basemap(region=region, projection="M8i", frame=True)#8i= taille, M=mercator
#fig.coast(W="1p", water="skyblue")
r=pygmt.makecpt(C="copper", T="0/1500",Z=True)
pygmt.grdgradient(grid="@eath_relief_01m", N="e0.8", A="100",f="g")
fig.grdimage(grid="@earth_relief_01m",R=region, C="copper", E=100)

Here’s the error:

makecpt [WARNING]: Without inc in -T option, -Z has no effect (ignored)
Traceback (most recent call last):

  File "C:\Users\Maureen\Downloads\", line 16, in <module>
    pygmt.grdgradient(grid="@eath_relief_01m", N="e0.8", A="100",f="g")

AttributeError: module 'pygmt' has no attribute 'grdgradient'

grdgradient is not implemented in PyGMT yet.

OK thanks for your answer but is there another module or way to have a more detailed map? The output is just blur, we can’t see the volcanoes or main faults…

You can just add shading=True to your grdimage call.

1 Like

Ok, sorry to bother you again but is there a way to tune the shading option or to increase the resoltution of the picture?

Yes, you can pass a string with illuminating parameters to the shading arg. e.g. shading='+a45+nt1'

1 Like

Thanks, do you know if there is a documentation for this?

Yes, sure. In the grdimage manual. All pygmt options accept the GMT options as strings, so the ultimate source of documentation is the GMT documentation itself.


Thanks very much for your help :blush:

This is great info for shading the grid image. It sounds like the functionality of grdgradient is essentially incorporated into the grdimage function. I recognize that the GMT documentation is the ultimate source of info, but it might be helpful for new users to see in the pyGMT manual that I=shading flag can accept “bool” or “str” (i.e. shading=True, or shading=’+a45+nt1’). Since the main GMT functions require users to use grdgradient first to create the netCDF and then use that as an input into grdimage, its unclear that grdimage does this shading on the fly.

The grdimage documentation discusses this and it calls grdgradient internally:

-I Apply directional illumination. Append name of intensity grid file.
   For a constant intensity (i.e., change the ambient light), just give a value.
   To derive intensities from <grid> instead, append +a<azim> [-45], +n<method> [t1], and +m<ambient> [0]
   or use -I+d to accept the default values (see grdgradient for details).
   To derive from another grid than <grid>, give an alternative data grid with modifiers.