When I execute the "raster.transform" function in Python it returns me a matrix.

enter image description here

What I can understand is that it tells me my data has a 10 m pixel resolution, It also tells me that my left bounding box is at 728749.5 and my top bounding box is at 4373200.5. What I don't understand is the rest of the elements like "-10", "1", and "0s". I also noticed that it can be a 2x3 matrix. Why is this dimension different?

enter image description here

I would like to know what does this matrix conveys and how can I use this information, especially when I have this info from two different rasters.


The .transform property returns an instance of an Affine object. This is essentially an augmented affine transformation matrix, where the 3x3 matrix always has a bottom row [0 0 1].

| x' |   | a  b  c | | x |
| y' | = | d  e  f | | y |
| 1  |   | 0  0  1 | | 1 |

The 2x3 matrix representation only shows the six coefficients (a, b, c, d, e, f) that represent this information. These coefficients are very similar to a 6-line world file, where the only difference is that a world file registers the offset to the centre of the origin cell, whereas GDAL (and rasterio) register the corner of the origin cell.

A few general remarks:

  • Coefficient a is generally the cell width along the x dimension. This is only true if b and d are zero.
  • Coefficient e is generally negative, since the y dimension is oriented in the opposite direction (upwards) to the raster row direction (downwards). Again, this is only true if b and d are zero.
  • Coefficients b and d are usually zero, unless this is an affine transform for a rotated or sheared raster. If they are not zero, then a and e don't represent cell dimensions.
  • Offsets c and f are usually to the corner of the upper-left cell.

Further reading:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.