Skip to content

Instantly share code, notes, and snippets.

Avatar

Nathan Woodrow NathanW2

View GitHub Profile
View gist:5a3d4c27e0e95e8739b254faecbc148e
bool enableMove = false, enableRotate = false, enablePin = false, enableShowHide = false, enableChange = false;
QMap<QString, QgsMapLayer*> layers = QgsMapLayerRegistry::instance()->mapLayers();
for ( QMap<QString, QgsMapLayer*>::iterator it = layers.begin(); it != layers.end(); ++it )
{
QgsVectorLayer *vlayer = qobject_cast<QgsVectorLayer *>( it.value() );
if ( !vlayer || !vlayer->isEditable() ||
( !vlayer->diagramsEnabled() && !vlayer->labelsEnabled() ) )
continue;
View gist:1562812886a26bdf6bd6
from PyQt4.QtCore import QPointF, QRectF, QTimer, QObject, pyqtProperty, QPropertyAnimation, Qt
from PyQt4.QtGui import QPainter, QBrush, QColor
from qgis.gui import QgsMapCanvasItem
from qgis.core import QgsPoint
class PingLocationMarker(QgsMapCanvasItem):
"""
Position marker for the current location in the viewer.
"""
class AniObject(QObject):
@NathanW2
NathanW2 / svg.py
Last active Feb 12, 2018
Web images as QGIS markers
View svg.py
import requests
import base64
@qgsfunction(args='auto', group='Custom')
def show_camera(feed, feature, parent):
svg = """
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg>
<g>
<image xlink:href="data:image/jpeg;base64,{0}" height="256" width="320" />
View keybase.md

Keybase proof

I hereby claim:

  • I am nathanw2 on github.
  • I am nathanw (https://keybase.io/nathanw) on keybase.
  • I have a public key whose fingerprint is B849 7CA0 ADD2 5303 8919 A42B E6AE 465E EFAF DFAE

To claim this, I am signing this object:

View gist:b8b40a7a02fa199c6076
class MyInterface:
def method1(self, arg):
pass
def method2(self, arg):
pass
class MyObject(MyInterface):
def method1(self, arg):
View env.bat
@ECHO OFF
REM ---------------------------------------------------------------------------------------
REM Change %OSGEO4W_ROOT% in setenv.bat to change in the location of QGIS.
REM ---------------------------------------------------------------------------------------
for %%x in (%cmdcmdline%) do if /i "%%~x"=="/c" set DOUBLECLICKED=1
REM Change OSGeo4W_ROOT to point to your install of QGIS.
View console.py
from PyQt4.QtGui import *
tab = QTabWidget()
mainwidget = iface.mainWindow().centralWidget().findChild(QStackedWidget)
mainwidget.layout().addWidget(tab)
tab.addTab(iface.mapCanvas(), "Canvas")
py = iface.mainWindow().findChild(QDockWidget, 'PythonConsole')
widget = py.widget()
editor = widget.findChild(QWidget, "EditorWidget")
View gist:d72c3397bd8cfb6424d9
QGraphicsOpacityEffect *effect = new QGraphicsOpacityEffect();
ui->label->setGraphicsEffect(effect);
QPropertyAnimation *anim = new QPropertyAnimation(effect,"opacity");
anim->setDuration(1000);
anim->setStartValue(1.0);
anim->setEndValue(0.0);
anim->setEasingCurve(QEasingCurve::OutQuad);
View max_name.py
from qgis.core import *
from qgis.gui import *
@qgsfunction(args=-1, group='Custom')
def max_name(fields, feature, parent):
realindex = [feature.fieldNameIndex(field) for field in fields]
values = [feature[field] for field in fields]
index = values.index(max(values))
index = realindex[index]
return feature.fields()[index].name()
View pythread.py
from PyQt4.QtCore import QThread, QObject, pyqtSignal
class Worker(QObject):
done = pyqtSignal()
finalResult = pyqtSignal(int)
def __init__(self, parent=None):
super(Worker, self).__init__(parent)
def do_stuff(self):
You can’t perform that action at this time.