2

Using PyGMT, I can make the following plot using the code as shown:

enter image description here

import pygmt

fig = pygmt.Figure()
with pygmt.config(FORMAT_GEO_MAP="ddd.x"):
    region = [-116.2, -115.45, 32.95, 33.65]
    projection = "M6i"

    fig.grdimage(
        "@earth_relief_01s",
        region=region,
        projection=projection,
        shading=True,
    )

    fig.coast(
        region=region,
        projection=projection,
        borders=["1/0.2p,black"],
        frame="a0.1f0.1",
        transparency=0,
    )
fig.show()

The topographic low feature (which is the Salton Sea) is oriented about -45 degrees. How can I rotate this type of map (e.g., relief grid) in PyGMT? I want something like this, but maybe capturing a wider area (i.e., most of the blue in the first image) and with ticks & grids for the lat/long.

I am completely new to GMT and relying on the PyGMT interface to make it a little easier for me.

enter image description here

1

1 Answer 1

6
+50

You will need to check for perspective param.

import pygmt

fig = pygmt.Figure()
"""
perspective : list or str
    [**x**\|\ **y**\|\ **z**]\ *azim*\[/*elev*\[/*zlevel*]]\
    [**+w**\ *lon0*/*lat0*\[/*z0*]][**+v**\ *x0*/*y0*].
    Select perspective view and set the azimuth and elevation angle of
    the viewpoint [Default is ``[180, 90]``]. Full documentation is at
    :gmt-docs:`gmt.html#perspective-full`.
"""


with pygmt.config(FORMAT_GEO_MAP="ddd.x", ):
    region = [-116.2, -115.45, 32.95, 33.65]
    projection = "M6i"
    perspective=[90, 90] ### Add perspective
    fig.grdimage(
        "@earth_relief_01s",
        region=region,
        projection=projection,
        shading=True,
        perspective=perspective #add to img
    )   
    fig.coast(
        region=region,
        projection=projection,
        borders=["1/0.2p,black"],
        frame="ag0.1f0.1", #add g to draw grid
        transparency=0,
        perspective=perspective #add to grid
    )   



fig.show()

perspective=[150, 90]

enter image description here

perspective=[90, 90]

enter image description here

1
  • Thank you so much!! You provided a perfect solution that was explained and demonstrated clearly; much appreciated
    – a11
    Dec 1, 2023 at 17:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.