[Qgis-developer] Learning to zoom with PyQGIS
m roy
royroge at outlook.com
Wed Jan 27 06:36:13 PST 2016
Hi,
i'm trying to learn a bit of "pyqgis" and cannot find how to zoom to
a certain scale,
here what i'm doing so far using QGIS python console:
###########################################
# Set some variables to define the layer
shapefile_path = r'C:\data\shp\area.shp'
legend_layer_name = 'sample_area'
provider_name = 'ogr'
# define the layer to load
layer = QgsVectorLayer(shapefile_path,legend_layer_name,provider_name)
# verify
if not layer.isValid():
raise IOError, "Failed to open the shapefile"
# load the layer in QGIS
QgsMapLayerRegistry.instance().addMapLayer(layer)
# now i can zoom to active layer i.e.
qgis.utils.iface.zoomToActiveLayer()
# or zoomFull zoomToNext zoomToPrevious
# How to zoom to say 1:10000 ?
#################################################
thanks for any help, Roy
#
More information about the Qgis-developer
mailing list