# segy2grd

Converting SEGY data to a grid

## Synopsis

gmt segy2grd segyfile -G grdfile -I increment -R region [ -A[n|z] ] [ -D-D[+x xname][+y yname][+z zname][+c[-|cpt]][+d dname][+s scale][+o offset][+n invalid][+t title][+r remark][+v varname] ] [ -L[nsamp] ] [ -M[ntraces] ] [ -Q x|y value ] [ -S[header] ] [ -V[level] ] [ -bi binary ] [ -di nodata[+c col] ] [ -:[i|o] ] [ --PAR=value ]

Note: No space is allowed between the option flag and the associated arguments.

## Description

segy2grd reads an IEEE SEGY file and creates a binary grid file. Either a simple mapping (equivalent to xyz2grd -Z) or a more complicated averaging where a particular grid cell includes values from more than one sample in the SEGY file can be done. segy2grd will report if some of the nodes are not filled in with data. Such unconstrained nodes are set to a value specified by the user [Default is NaN]. Nodes with more than one value will be set to the average value.

## Required Arguments

segyfile is an IEEE floating point SEGY file. Traces are all assumed to start at 0 time/depth.

-G outgrid[=ID][+d divisor][+n invalid][+o offset|a][+s scale|a][:driver[dataType][+c options]]

> Optionally, append =ID for writing a specific file format. The following modifiers are supported:

> > - +d - Divide data values by given divisor [Default is 1].

> > - +n - Replace data values matching invalid with a NaN.

> > - +o - Offset data values by the given offset, or append a for automatic range offset to preserve precision for integer grids [Default is 0].

> > - +s - Scale data values by the given scale, or append a for automatic scaling to preserve precision for integer grids [Default is 1].

> Note: Any offset is added before any scaling. +sa also sets +oa (unless overridden). To write specific formats via GDAL, use =gd and supply driver (and optionally dataType) and/or one or more concatenated GDAL -co options using +c. See the “Writing grids and images” cookbook section for more details.

-I

  x_inc [and optionally y_inc] is the grid spacing. Append m to indicate minutes or s to indicate seconds.

-R west/east/south/north[/zmin/zmax][+r][+u unit]

> Specify the region of interest.

> The region may be specified in one of several ways:

> 1. -R west/east/south/north. This is the standard way to specify geographic regions when using map projections where meridians and parallels are rectilinear. The coordinates may be specified in decimal degrees or in [±]dd:mm[:ss.xxx][W|E|S|N] format.

> 2. -R west/south/east/north+r. This form is useful for map projections that are oblique, making meridians and parallels poor choices for map boundaries. Here, we instead specify the lower left corner and upper right corner geographic coordinates, followed by the modifier +r. This form guarantees a rectangular map even though lines of equal longitude and latitude are not straight lines.

> 3. -R g or -R d. These forms can be used to quickly specify the global domain (0/360 for -Rg and -180/+180 for -Rd in longitude, with -90/+90 in latitude).

> 4. -R code1,code2,…[+e|r|R incs]. This indirectly supplies the region by consulting the DCW (Digital Chart of the World) database and derives the bounding regions for one or more countries given by the codes. Simply append one or more comma-separated countries using either the two-character ISO 3166-1 alpha-2 convention (e.g., NO) or the full country name (e.g., Norway). To select a state within a country (if available), append .state (e.g, US.TX), or the full state name (e.g., Texas). To specify a whole continent, spell out the full continent name (e.g., -RAfrica). Finally, append any DCW collection abbreviations or full names for the extent of the collection or named region. All names are case-insensitive. The following modifiers can be appended:

>    > - +r to adjust the region boundaries to be multiples of the steps indicated by inc, xinc/yinc, or winc/einc/sinc/ninc [default is no adjustment]. For example, -R FR+r1 will select the national bounding box of France rounded to nearest integer degree, where inc can be positive to expand the region or negative to shrink the region.

>    > - +R to adjust the region by adding the amounts specified by inc, xinc/yinc, or winc/einc/sinc/ninc [default is no extension], where inc can be positive to expand the region or negative to shrink the region.

>    > - +e to adjust the region boundaries to be multiples of the steps indicated by inc, xinc/yinc, or winc/einc/sinc/ninc, while ensuring that the bounding box is adjusted by at least 0.25 times the increment [default is no adjustment], where inc can be positive to expand the region or negative to shrink the region.

> 5. -R xmin/xmax/ymin/ymax[+u unit] specifies a region in projected units (e.g., UTM meters) where xmin/xmax/ymin/ymax are Cartesian projected coordinates compatible with the chosen projection (-J) and unit is an allowable distance unit [e]; we inversely project to determine the actual rectangular geographic region. For projected regions centered on (0,0) you may use the short-hand -R halfwidth[/halfheight]+u unit, where halfheight defaults to halfwidth if not given. This short-hand requires the +u modifier.

> 6. -R justify lon0/lat0/nx/ny, where justify is a 2-character combination of L|C|R (for left, center, or right) and T|M|B (for top, middle, or bottom) (e.g., BL for lower left). The two character code justify indicates which point on a rectangular region region the lon0/lat0 coordinates refer to and the grid dimensions nx and ny are used with grid spacings given via -I to create the corresponding region. This method can be used when creating grids. For example, -RCM 25/25/50/50 specifies a 50x50 grid centered on 25,25.

> 7. -R gridfile. This will copy the domain settings found for the grid in specified file. Note that depending on the nature of the calling module, this mechanism will also set grid spacing and possibly the grid registration (see Grid registration: The -r option).

> 8. -Ra[uto] or -Re[xact]. Under modern mode, and for plotting modules only, you can automatically determine the region from the data used. You can either get the exact area using -Re [Default if no -R is given] or a slightly larger area sensibly rounded outwards to the next multiple of increments that depend on the data range using -Ra.

## Optional Arguments

-A[n|z]

  Add up multiple values that belong to the same node (same as -Az). Append n to simply count the number of data points that were assigned to each node. [Default (no -A option) will calculate mean value]. Not used for simple mapping.

-D[+x xname][+y yname][+z zname][+c[-|cpt]][+d dname][+s scale][+o offset][+n invalid][+t title][+r remark][+v varname]

  Control names and units of netCDF grid and cube meta-data. For dimensions with units, add the unit in square bracket (e.g., “distance [km]”). Select one or more of these modifiers:

  - +c - Append cpt to set a default CPT for this grid [turbo] or give - to remove any default CPT already set.

  - +d - Set dname, the data value name.

  - +n - Set the invalid number used to indicate a NaN or missing value.

  - +o - Set the offset to add to data after first scaling the data [0].

  - +r - Set a remark used for this grid (any sentence you prefer).

  - +s - Set the scale used fto multiply data values after they are read [1].

  - +t - Set a title used for this grid (any sentence you prefer).

  - +v - Append varname, the variable name of the data set.

  - +x - Append xname, the name of the x-coordinate (and optional unit in brackets).

  - +y - Append yname, the name of the y-coordinate (and optional unit in brackets).

  - +z - For 3-D cubes; append zname, the name of the z-coordinate (and optional unit in brackets).

  Give a blank name to completely reset a particular string. Use quotes to group texts with more than one word. If any of your text contains plus symbols you need to escape them (place a backslash before each plus-sign) so they are not confused with the option modifiers. Alternatively, you can place the entire double-quoted string inside single quotes. If you have shell variables that contain plus symbols you cannot use single quotes but you can escape the plus symbols in a variable using constructs like ${variable/+/\+}. Note that for geographic grids and cubes (-fg), xname and yname are set automatically. Normally, the data netCDF variable is called “z” (grid) or “cube” (data cube). You can rename this netCDF variable via +v.

-L

  Let nsamp override number of samples in each trace.

-M[ntraces]

  Fix number of traces to read in. Default tries to read 10000 traces. -M0 will read number in binary header, -M ntraces will attempt to read only n traces.

-Q x|y value
  Can be used to change two different settings depending on the directive:

    -Qx x-scale applies scalar x-scale to coordinates in trace header to match the coordinates specified in -R.

    -Qy s_int specifies sample interval as s_int if incorrect in the SEGY file. Repeatable.

-S[header]

  Set variable spacing; header is c for cdp, o for offset, or b number for 4-byte float starting at byte number. If -S not set, assumes even spacing of samples at the x_inc, y_inc supplied with -I.

-V[level]

  Select verbosity level [w]. (See full description) (See cookbook information).

-di nodata[+c col] (more …)

  Replace input columns that equal nodata with NaN. Also sets nodes with no input SEGY coverage to this value [Default is NaN].

-r[g|p] (more …)

  Set node registration [gridline].

-^ or just -

  Print a short message about the syntax of the command, then exit (Note: on Windows just use -).

-+ or just +

  Print an extensive usage (help) message, including the explanation of any module-specific option (but not the GMT common options), then exit.

-? or no arguments

  Print a complete usage (help) message, including the explanation of all options, then exit.

--PAR=value

  Temporarily override a GMT default setting; repeatable. See gmt.conf for parameters.

## Examples

To create a grid file from an even spaced SEGY file test.segy, try:

    gmt segy2grd test.segy -I0.1/0.1 -Gtest.nc -R198/208/18/25 -V

Note that this will read in 18-25s (or km) on each trace, but the first trace will be assumed to be at X=198

To create a grid file from the SEGY file test.segy, locating traces according to the CDP number, where there are 10 CDPs per km and the sample interval is 0.1, try:

    gmt segy2grd test.segy -Gtest.nc -R0/100/0/10 -I0.5/0.2 -V -Qx0.1 -Qy0.1

Because the grid interval is larger than the SEGY file sampling, the individual samples will be averaged in bins

## See Also

gmt, grd2xyz, grdedit, segy, xyz2grd