Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

After much searching, I've still not been able to figure out how to perform what seems like a simple function: I'd like to get the pixel size/cell size of a raster layer using PyQgis. Is there any native way to do this through QgsRasterLayer or a helper class? Or will I need to read the file in using GDAL functions, e.g.:

geotransform = dataset.GetGeoTransform()
if not geotransform is None:
    print 'Pixel Size = (',geotransform[1], ',',geotransform[5],')'

Thanks for your help.


share|improve this question
What format are your rasters in? It is often possible to parse the resolution out of a raster's header. – sgrieve Nov 16 '12 at 8:43
up vote 2 down vote accepted

You tagged your question with pyqgis. Here is a small solution using the Pyqgis modules

# Get a QgsRasterLayer object
ras = [yourObject]
pixelSizeX = ras.rasterUnitsPerPixelX()
pixelSizeY = ras.rasterUnitsPerPixelY()
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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