qgis python map canvas saveimageas save wrong image

المشرف العام

Administrator
طاقم الإدارة
I've been trying to write a small python script to output 2 tif's based on given box extents. The script all works, box coordinates convert to project coordinates, zooms to right place (would like it to pause between zoom changes), just the 2 outputs are wrong, they both show the image that was displaying before the script is run.

import qgis.utils import time source_crs = QgsCoordinateReferenceSystem(4326)#heographic dest_crs = QgsCoordinateReferenceSystem(3857) transform = QgsCoordinateTransform(source_crs, dest_crs) myBox = QgsRectangle(0, 51,2,53) new_box = transform.transformBoundingBox(myBox) canvas = qgis.utils.iface.mapCanvas() canvas.setExtent(new_box) #canvas.clearExtentHistory() #canvas.clearCache(); canvas.refresh() canvas.saveAsImage("c:/data/qgis_image.tif" ,None ,"TIF") myBox = QgsRectangle(-4, 51,0,53) new_box = transform.transformBoundingBox(myBox) canvas = qgis.utils.iface.mapCanvas() canvas.setExtent(new_box) #canvas.clearExtentHistory() #canvas.clearCache(); canvas.refresh() canvas.saveAsImage("c:/data/qgis_image2.tif" ,None ,"TIF")

أكثر...
 
أعلى