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.core import * | |
from qgis.gui import * | |
from PyQt4.QtCore import * | |
from PyQt4.QtGui import QApplication | |
from PyQt4.QtXml import * | |
import sys | |
import xml.etree.ElementTree as ET | |
QGISAPP = QgsApplication(sys.argv, True) |
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.core import * | |
from qgis.gui import * | |
from PyQt4.QtCore import * | |
from PyQt4.QtGui import QApplication | |
from PyQt4.QtXml import * | |
import sys | |
import xml.etree.ElementTree as ET | |
app = QgsApplication([], True) |
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
@qgsfunction(2, "Geometry") | |
def azimuth(values, feature, *args): | |
geom = feature.geometry() | |
if geom is None: return None | |
if geom.type() == QGis.Line: | |
xy = geom.asPolyline() | |
p1 = xy[values[0].toInt()[0]] | |
p2 = xy[values[1].toInt()[0]] | |
return p1.azimuth(p2) |
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
lyr = qgis.utils.iface.activeLayer() | |
lyr.select([]) | |
for feature in lyr: | |
buff = feat.geometry().buffer(5,2) | |
lyr.dataProvider().changeGeometryValues({feat.id(): buff}) |
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
class geo(): | |
pass | |
class fTools(geo): | |
pass | |
class fTools2(geo): | |
pass | |
class fTools3(geo): |
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 PyQt4.QtCore import * | |
name_field = 'NAME' | |
sum_field = 'POP_EST' | |
neighbors_field = 'Neighbors' | |
total_field = 'Sum' | |
layer = qgis.utils.iface.activeLayer() | |
provider = layer.dataProvider() | |
layer.startEditing() | |
neighbor_name_index = provider.fieldNameIndex(neighbors_field) |
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
def where(layer, expression): | |
for f in layer: | |
if expression.evaluate(f).toBool(): | |
yield f | |
exp = QgsExpressin('"Col" = 99') | |
exp.prepare(layer.fields()) | |
items = where(layer, exp) |
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: |
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.gui import QgsMapCanvas, QgsMapCanvasLayer | |
from PyQt4.QtGui import QFrame | |
def formOpen(dialog, layer, feature): | |
canvas = QgsMapCanvas() | |
canvas.setCanvasColor(QColor(255,255,255)) | |
frame = dialog.findChild(QFrame,"frame") | |
frame.layout().addWidget(canvas) | |
c_layer = QgsMapCanvasLayer(layer) |
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
@echo off | |
set OSGEO4W_ROOT=C:\OSGeo4W | |
set OSGEO4W_ROOT=%OSGEO4W_ROOT:\\=\% | |
set PATH=%OSGEO4W_ROOT%\bin;%PATH% | |
for %%f in ("%OSGEO4W_ROOT%\etc\ini\*.bat") do call "%%f" | |
set PYTHONPATH=C:\OSGeo4W\apps\qgis-dev\python | |
Set PATH=C:\OSGeo4W\apps\qgis-dev\bin;%PATH% | |
set QGISHOME=C:\OSGeo4W\apps\qgis-dev\ |