Pygmt.grdcontour - Dump contours as data line segments (?)

Hello fellow Pygmtnians,
Checking pygmt’s grdcontour documentation, I noticed that it doesn’t have the (fantastic!) option to Dump contours as data line segments, as a file or as an array. Is that right or does it exist and I didn’t find it?
Cheers

Hello @andrebelem,

so far no alias for the D flag of grdcontour is available in PyGMT.

In the meanwhile, you can try using D itself to write the contour lines as data line segments to a text file. Please note, I did not check in detail, whether all functionality, which is documented in the upstream GMT documentation (https://docs.generic-mapping-tools.org/latest/grdcontour.html#d) is available.

import pygmt

study_region = [0, 20, 40, 50]

# Download Earth relief data
grid_relief = pygmt.datasets.load_earth_relief(
    region=study_region,
    resolution="15m",
    registration="gridline",
)

# Create new figure intance
fig = pygmt.Figure()

fig.grdcontour(
    projection="M10c",
    region=study_region,
    frame=True,
    grid=grid_relief,
    interval=500,
    # Write contour lines to txt file, do NOT plot something
    D="export_contours_relief.txt",
)

Cool ! Many thans @yvonnefroehlich. It worked !