I found the this to export the current view as image. The following code works and was accepted as answer.

c = iface.activeComposers()[0].composition()

image = c.printPageAsRaster(0)


Sadly the images produced by this code are not georeferenced, even if I use different image formats.

How is it possible to programmatically export current view as georeferenced image with QGis?


You could use:

iface.mapCanvas().saveAsImage( "myGeoreferencedView.png" )

It exports both PNG and PNGw files. The latter is known as World file and contains coordinate information.

  • But not the crs, though maybe there is a gdal aux created as well?
    – mdsumner
    May 23 '16 at 13:28
  • Nope, only two files are generated. You can choose among several formats like TIF or TIFF, but you'll only get the raster and its corresponding World file. May 23 '16 at 13:50
  • I requested GTiff some years ago, they may be ready for this now? It's a real lost opp
    – mdsumner
    May 23 '16 at 21:56

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.