I have data in a matrix form. How can I use this to create a map in Surfer?

Surfer 13 (and newer versions) can read uniformly spaced data in matrix format directly as a grid file. To create a grid-based map from matrix data in Surfer:
  1. Save the matrix data in a TXT, CSV, DAT or FTG file format.
  2. Click Home | New Map | Contour or the grid-based map type you wish to create.
  3. In the Open Grid dialog, change the Files of type to TXT Formatted Text Grid.
  4. Select the data file and click Open.
  5. If the Select Format dialog appears, select TXT Formatted Text Grid from the list and click OK.
  6. In the Formatted Text Grid Import Options, select the options that define how the matrix data is organized.
  7. Click OK and the map is created.


If you are using Surfer 12 or a previous version, you can convert the matrix data to a grid file to use to create a map. You can do this by either converting the matrix data to XYZ data and gridding it, or converting the matrix data directly to a text grid.


Option 1: Converting the matrix to an XYZ data file and gridding the data.

  1. Download the attached example script Matrix2XYZ.bas.
  2. Open Scripter, which comes with Surfer, open the script, and click Script | Run to run it. The script converts data in matrix format to data in XYZ format.
  3. After the data is converted, click Grid | Data in Surfer to grid the data and generate the grid file. I recommend gridding the data using the Nearest Neighbor gridding method, setting the Spacing value to be equal to the spacing in the matrix data file.


Option 2: Converting the matrix directly to a text grid file.

A text grid file has a 5 line header followed by a list of Z values, from left to right, bottom to top. If the grid file is reversed in either the X or Y direction (depending on the data listing in the matrix file), then reverse the grid file so that the X or Y data is going the right direction. To do this:

  1. Save your data in a text file (e.g. DAT, TXT, CSV, etc).
  2. Open it in a text editor (like Notepad).
  3. Remove the header row or header column from the matrix if necessary.
  4. Add a 5-line header at the very top, so that you just see the 5-line header and a list of Z values. The 5-line header is simply:
    1. DSAA
    2. # of lines in X # of lines in Y
    3. Xmin Xmax
    4. Ymin Ymax
    5. Zmin Zmax
      Converting a matrix to a grid file for use in Surfer
  5. Click File | Save As and save it with a .grd extension (put the name in quotes "testgrid.grd"). This will be in the correct format to create a map.
  6. If the X or Y data are reversed, click Grid | Calculate | Transform, select the grid file and click Open.
  7. In the Grid Transform dialog, select either the Mirror X or the Mirror Y as the Operation, and click OK. This is the grid with the data in the correct orientation.


Updated November 9, 2018

Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request


Please sign in to leave a comment.