The extractions fails with error:
File “/Users/rex/anaconda3/envs/pygmt/lib/python3.9/site-packages/pygmt/helpers/utils.py”, 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?
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?
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.
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.
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")
print(track)