This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from qgis.utils import iface | |
from PyQt4.QtCore import * | |
from PyQt4.QtGui import * | |
def snapping_toggle(): | |
#layer = QgsMapLayerRegistry.instance().mapLayersByName("topographicline")[0] | |
layer = iface.activeLayer() | |
_, enabled, _, _, _, _ = QgsProject.instance().snapSettingsForLayer(layer.id()) | |
QgsProject.instance().setSnapSettingsForLayer(layer.id(), not enabled, 0, 1, 10, True) | |
print "set {} snapping {}".format(layer.name(), "Off" if not enabled else "On") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from qgis.utils import iface | |
from qgis.core import QGis | |
from qgiscommand.command import command | |
@command() | |
def bbox(): | |
layer = iface.activeLayer() | |
def pbounds (Lextent,s): | |
e = Lextent |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import sys | |
import sip | |
from qgis.core import ( | |
QgsApplication, QgsVectorLayer, QgsField, | |
QgsFields, QgsFeature, QgsGeometry, QgsPoint, QgsMapLayerRegistry) | |
from PyQt4.QtCore import QVariant |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
computeFieldIndex = layer.fieldNameIndex('population') | |
allFieldsMap = layer.pendingFields() | |
expression = QgsExpression('"affected" = 1') | |
expression.prepare(allFieldsMap) | |
if expression.hasParserError(): | |
raise Exception('Parser error !!') | |
def getFeatures(): | |
if self.selectedOnly: |