pygmt.grd2xyz
- pygmt.grd2xyz(grid, output_type='pandas', outfile=None, *, region=None, verbose=None, outcols=None, **kwargs)[source]
- Convert grid to data table. - Read a grid and output xyz-triplets as a - numpy.ndarray,- pandas.DataFrame, or ASCII file.- Full option list at https://docs.generic-mapping-tools.org/latest/grd2xyz.html - Aliases: - R = region 
- V = verbose 
- o = outcols 
 - Parameters
- grid (str or xarray.DataArray) – The file name of the input grid or the grid loaded as a - xarray.DataArray. This is the only required parameter.
- output_type (str) – - Determine the format the xyz data will be returned in [Default is - pandas]:- numpy-- numpy.ndarray
- pandas-- pandas.DataFrame
- file- ASCII file (requires- outfile)
 
- outfile (str) – The file name for the output ASCII file. 
- region (str or list) – Required if this is the first plot command. xmin/xmax/ymin/ymax[+r][+uunit]. Specify the region of interest. Adding - regionwill select a subsection of the grid. If this subsection exceeds the boundaries of the grid, only the common region will be output.
- 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 algorithms); 
- i - Informational messages (same as - verbose=True)
- c - Compatibility warnings 
- d - Debugging messages 
 
- outcols (str or 1d array) – - cols[,…][,t[word]]. Specify data columns for primary output in arbitrary order. Columns can be repeated and columns not listed will be skipped [Default writes all columns in order, starting with the first (i.e., column 0)]. - For 1d array: specify individual columns in output order (e.g., - outcols=[1,0]for the 2nd column followed by the 1st column).
- For - str: specify individual columns or column ranges in the format start[:inc]:stop, where inc defaults to 1 if not specified, with columns and/or column ranges separated by commas (e.g.,- outcols="0:2,4"to output the first three columns followed by the 5th column). To write from a given column until the end of the record, leave off stop when specifying the column range. To write trailing text, add the column t. Append the word number to t to write only a single word from the trailing text. Instead of specifying columns, use- outcols="n"to simply read numerical input and skip trailing text. Note: if- incolsis also used then the columns given to- outcolscorrespond to the order after the- incolsselection has taken place.
 
 
- Returns
- ret (pandas.DataFrame or numpy.ndarray or None) – Return type depends on - outfileand- output_type:- None if - outfileis set (output will be stored in file set by- outfile)
- pandas.DataFrameor- numpy.ndarrayif- outfileis not set (depends on- output_type)