Grids Rasters and XYZ Files:

 

Background

General XYZ Export

Most earth scientists have always dealt with their grid/raster data with the firm assumption that Z values in grids (and in exported XYZ products) represented the central values for the grid cells, AND that description of the grids referred to the geographic locations of these centers. Thus, when you read phrases such as "first longitude" or "first latitude" in the metadata, you can be reasonably sure that the cell centers are provided. Software to handle these files (grids/rasters and XYZ) simply used the first latitude and first longitude as anchor points on the map, and then placed (or derived) the other points by adding spatial increments (the delta-x and delta-y values) towards the east and north (or sometimes the east and south) respectively.

Delta Y Issues

The authors are unaware of any geographic data grids in the earth sciences that move toward the west from the first longitude. But regarding the first latitude, there is no such unanimity at all. Many raster (i.e. image) formats move southward from a first latitude at the top left corner, and many data grid formats move northward from the bottom left corner, but there are many, many exceptions. Thus delta-y, the spacing between adjacent data rows can be negative (for a first latitude in the upper left corner), because you are "moving down" through the grid as you advance through the rows. And the delta-y can be positive (for a first latitude in the lower left corner), for the opposite reason. In the former case we should call it a "decrement," and in the latter case we should call it an "increment."

Arc Grid ASCII Example

Here is the beginning few lines of a typical grid downloaded from the US National Virtual Ocean Data System (NVODS). It depicts the U component of shipdrift (in cm/s) for a location offshore Namibia, for January (a climatological monthly average). Notice that the file uses the CORNER-syntax to specify the relation between the latitude/longitude values given (-37 and 1) and the physical placement of the cell.

ncols 26
nrows 27
xllcorner 1
yllcorner -37
cellsize 1
nodata_value -9999
  5.567000    
 -22.35000    
 -10.38000    
 -11.40000    
  7.000000    
 -19.20000    
-9999
-9999
-9999
-9999
 -7.575000    
 -23.10000    
-9999
-9999
-9999
-9999
-9999
-9999
-9999
-9999
-9999
-9999
-9999
-9999
-9999
-9999
 -3.500000    
 -6.750000
etc.    

XYZ Export Product

But here is the XYZ format product file that can be derived from the above grid. Notice that the first longitude is 1.5, not 1 (the value of xllcorner). The first latitude value is -36.5, not -37(the value of yllcorner). Both xllcorner and yllcorner have been adjusted by exactly one-half the cellsize (or by 0.5) to "move" them to the center of the lower left cell. [If, on the other hand, you export an XYZ file from an Arc Grid file that uses the CENTER-syntax, then the first values for longitude and latitude will be exactly the same as the XLLCENTER and YLLCENTER values in the header.]

"X"	        "Y"	        "u"
1.500000	-36.500000	20.667000
2.500000	-36.500000	6.600000
3.500000	-36.500000	0.000000
4.500000	-36.500000	7.150000
5.500000	-36.500000	2.133000
6.500000	-36.500000	-5.100000
7.500000	-36.500000	10.800000
8.500000	-36.500000	10.500000
9.500000	-36.500000	6.983000
10.500000	-36.500000	0.667000
11.500000	-36.500000	3.075000
12.500000	-36.500000	0.340000
13.500000	-36.500000	-11.650000
14.500000	-36.500000	-11.083000
15.500000	-36.500000	8.033000
16.500000	-36.500000	-9999.000000
17.500000	-36.500000	-12.850000
18.500000	-36.500000	-36.099998
19.500000	-36.500000	-50.132999
20.500000	-36.500000	-21.167000
21.500000	-36.500000	-5.000000
22.500000	-36.500000	-0.050000
23.500000	-36.500000	-25.700001
24.500000	-36.500000	-14.875000
25.500000	-36.500000	-11.125000