Grdtrack not working when no points are provided


I’m trying to extract the elevation along a profile knowing its start and end point (A and B)
First I get the grid from the SRTM mission:

grid = pygmt.datasets.load_earth_relief(resolution=“01s”, region=region)

Then I use grdtrack using the “profile” option, since I want grdtrack to generate the sampling points between A and B with an increment of 1 km:

profile = ‘14.33/41.43/14.93/41.14+i1’
track = pygmt.grdtrack(points = None, grid = grid, profile = profile)

The extractions fails with error:
File “/Users/rex/anaconda3/envs/pygmt/lib/python3.9/site-packages/pygmt/helpers/”, line 69, in data_kind
raise GMTInvalidInput(“No input data provided.”)

To me It seems that the grid is not correctly read. Am I doing something wrong?
Any clue on how to solve this?


Pretty sure +i1 means 1 spherical degree which is less than your total distance. Try +i1e-6. Looks like there is no option to do things like +i1k.

Unfortunately it is still not working. Even removing that +i option at all…

Mmm, maybe you could try with another grid (to see if there is a problem on it)? Or maybe run gmt grdinfo “grid” (sorry, I don’t know the pygmt syntax) to see how GMT read it?

These are the try I’ve made

  1. Run this example code that uses grdtrack to extract the bathimetry (from the earth relief as in my case) at given points. It works perfectly, meaning that grdtrack works fine on my machine.
  2. I used the same grid as in point 1) to extract along a profile from A to B, as in the original post. I got the same error. This means that the use of a different grid does not solve the problem and the bug probably resides on grdtrack whenever the “profile” is used.

Any other clue from your side?


I agree. I am afraid I am not familiar with the profile syntax in pygmt.

Hi @19giovi87, I noticed your bug report at and have posted a reply there. There was an issue with GitHub today that might mean notifications weren’t sent, so I’ll just copy my workaround code here:

import pandas as pd
import pygmt
import numpy as np

region = [14.1, 15.2, 41.0, 41.6]
grid = pygmt.datasets.load_earth_relief(resolution="01s", region=region)

profile = "14.33/41.43/14.93/41.14"  # these are the coordinates of A and B

points = pd.DataFrame(
    data=np.linspace(start=(14.33, 41.43), stop=(14.93, 41.14), num=250),
    columns=["x", "y"],

track = pygmt.grdtrack(points=points, grid=grid, newcolname="elevation")


	x	y	elevation
0	14.330000	41.430000	1294.000000
1	14.332410	41.428835	1389.962382
2	14.334819	41.427671	1445.901806
3	14.337229	41.426506	1397.092802
4	14.339639	41.425341	1472.605211
...	...	...	...
245	14.920361	41.144659	235.882504
246	14.922771	41.143494	215.088483
247	14.925181	41.142329	170.312853
248	14.927590	41.141165	158.030026
249	14.930000	41.140000	173.000000

250 rows × 3 columns

based on this chunk of code:

Thank you @weiji14 :slight_smile: