If the raster is not rotated, the pixel x & y dimensions are the 2nd and 6th elements in the geoTransform
:
gdalinfo -json utm.tif
Output:
{
"description":"utm.tif",
"driverShortName":"GTiff",
"driverLongName":"GeoTIFF",
"files":[
"utm.tif"
],
"size":[
512,
512
],
"geoTransform":[
440720.0,
60.0, # <--- pixel width
0.0,
3751320.0,
0.0,
-60.0 # <--- pixel height (negative because image coordinates are top down, but map coordinates are bottom up)
], <snip>
Note for rotated rasters:
In a GDAL geotransform, the second and last values are not actually "the pixel size". They are parameters of an affine transformation. However they are equal to the pixel size where there's no rotation.
The Wikipedia entry on ESRI world files has a good explanation (note GDAL geotransforms are in CABFDE order):
The generic meaning of the six parameters in a world file (as defined by Esri) are:
- C: x-coordinate of the center of the upper left pixel
- A: pixel size in the x-direction in map units/pixel
- B: rotation about x-axis
- F: y-coordinate of the center of the upper left pixel
- D: rotation about y-axis
- E: pixel size in the y-direction in map units, almost always negative
This description
is however misleading in that the D and B parameters are not angular
rotations, and that the A and E parameters do not correspond to the
pixel size if D or B are not zero. The A, D, B and E parameters are
sometimes named "x-scale", "y-skew", "x-skew" and "y-scale".
A better description of the A, D, B and E parameters are:
- A: x-component of the pixel width (x-scale)
- B: x-component of the pixel height (x-skew)
- D: y-component of the pixel width (y-skew)
- E: y-component of the pixel height (y-scale), typically negative
All four parameters are expressed in the map units, which are described by the spatial reference system for the raster.
When D or B are non-zero the pixel width is given by:
and the pixel height by: