Skip to content

Instantly share code, notes, and snippets.

Avatar

Nathan Woodrow NathanW2

View GitHub Profile
View style.qss
QToolTip
{
border: 1px solid #222;
background-color: #333;
color: @text;
}
QWidget
{
color: @text;
View gist:9082393
index = self.cmbConnectionsServices.findText(to_select)
if index == -1:
index = 0
if not to_select:
index = self.cmbConnectionServices.count() - 1
self.cmbConnectionServices.setCurrentIndex(index)
View README.md

Usage:

js = JSCaller(frame)
js.someJsMethod({"arg1":'test'}, "Hello World")
View gist:fe6966e56af8a799eb44
e import QgsApplication, QgsMapLayerRegistry
from qgis.gui import QgsMapCanvas
from qgis.core import QgsVectorLayer
from contextlib import contextmanager
@contextmanager
def qgisapp():
GUIEnabled=True
app = QgsApplication([], GUIEnabled)
View gist:2bcbdab504dbd2ad6a02
FOREACH(module core)
ADD_CUSTOM_TARGET(py${module} ALL)
FILE(GLOB_RECURSE PY_FILES "${module}/*.py")
INSTALL(FILES ${PY_FILES} DESTINATION "${QGIS_PYTHON_DIR}/${module}")
ADD_CUSTOM_COMMAND(TARGET py${module}
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory "${QGIS_PYTHON_OUTPUT_DIRECTORY}/${module}"
COMMAND ${CMAKE_COMMAND} -E copy ${PY_FILES} "${QGIS_PYTHON_OUTPUT_DIRECTORY}/${module}"
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
View .gitconfig
[core]
autocrlf = true
[alias]
st = status -s
ci = commit
br = branch
co = checkout
amend = commit --amend
aa = add --all
ac = add -u
View gist:8c981db9b31d00457cc0
def change_values(layer, **kwargs):
featuremap = {}
for feature, values in kwargs.iteritems():
attrs = {}
for field, value in values.iteritems():
index = layer.dataProvider().fieldNameIndex(field)
attrs[index] = value
featuremap[feature.id()] = attrs
return layer.dataProvider().changeAttributeValues(featuremap)
View Usage.md

Usage:

>>> selection.update(field1=1, field2="balh")
>>> selection['mylayer'].update(field1=1, field2="balh")
View gist:a51303bcb7bb0390b8db
import os
import sys
import glob
import expressions
from qgis.core import QgsApplication
def load_user_expressions(path):
"""
Load all user expressions from the given paths
@NathanW2
NathanW2 / import.bat
Last active Aug 29, 2015
Import file to SQL Sever using OGR2OGR (drag and drop file onto batch file to import that file)
View import.bat
REM Drag and drop OGR2OGR file for importing a layer into the database
REM Drop a file that OGR supports to kick off import
@ECHO OFF
SET dbserver=localhost\SQLEXPRESS
SET dbname=Test
SET db="MSSQL:server=%dbserver%;database=%dbname%;trusted_connection=yes"
SET ARGS=-s_src EPSG:28356 -progress -overwrite -lco GEOM_NAME:SP_GEOMETRY
You can’t perform that action at this time.