pygmt.grdtrack¶
-
pygmt.
grdtrack
(points, grid, newcolname=None, outfile=None, **kwargs)[source]¶ Sample grids at specified (x,y) locations.
Grdtrack reads one or more grid files and a table with (x,y) [or (lon,lat)] positions in the first two columns (more columns may be present). It interpolates the grid(s) at the positions in the table and writes out the table with the interpolated values added as (one or more) new columns. A bicubic [Default], bilinear, B-spline or nearest-neighbor interpolation is used, requiring boundary conditions at the limits of the region (see
interpolation
; Default uses “natural” conditions (second partial derivative normal to edge is zero) unless the grid is automatically recognized as periodic.)Full option list at https://docs.generic-mapping-tools.org/latest/grdtrack.html
Aliases:
V = verbose
n = interpolation
- Parameters
points (pandas.DataFrame or str) – Either a table with (x, y) or (lon, lat) values in the first two columns, or a filename (e.g. csv, txt format). More columns may be present.
grid (xarray.DataArray or str) – Gridded array from which to sample values from, or a filename (netcdf format).
newcolname (str) – Required if
points
is apandas.DataFrame
. The name for the new column in the trackpandas.DataFrame
table where the sampled values will be placed.outfile (str) – Required if
points
is a file. The file name for the output ASCII file.Select verbosity level [Default is w], which modulates the messages written to stderr. Choose among 7 levels of verbosity:
q - Quiet, not even fatal error messages are produced
e - Error messages only
w - Warnings [Default]
t - Timings (report runtimes for time-intensive algorthms);
i - Informational messages (same as
verbose=True
)c - Compatibility warnings
d - Debugging messages
interpolation (str) –
[b|c|l|n][+a][+bBC][+c][+tthreshold]. Select interpolation mode for grids. You can select the type of spline used:
b for B-spline
c for bicubic [Default]
l for bilinear
n for nearest-neighbor
- Returns
track (pandas.DataFrame or None) – Return type depends on whether the
outfile
parameter is set:pandas.DataFrame
table with (x, y, …, newcolname) ifoutfile
is not setNone if
outfile
is set (track output will be stored in file set byoutfile
)