Skip to content

Instantly share code, notes, and snippets.

Nathan Woodrow NathanW2

Block or report user

Report or block NathanW2

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:f4dd3db11e19337dedf7b393270c10db
SET OSGEO4W_ROOT=C:\Program Files\QGIS 3.2
SET QGISNAME=qgis
SET QGIS=%OSGEO4W_ROOT%\apps\%QGISNAME%
set QGIS_PREFIX_PATH=%QGIS%
CALL "%OSGEO4W_ROOT%\bin\qt5_env.bat"
CALL "%OSGEO4W_ROOT%\bin\py3_env.bat"
set PATH=%OSGEO4W_ROOT%\bin;%QGIS%\bin;C:\Program Files (x86)\Git\bin;%PATH%;
set PYTHONPATH=%PYTHONPATH%;%QGIS%\python
View gist:2e9ef2e4a8caa5e1d326d4602d41f3c3
SET ROOT=C:\Program Files\QGIS 3.0
CALL "%ROOT%\bin\o4w_env.bat"
CALL "%ROOT%\bin\py3_env.bat"
CALL "%ROOT%\bin\qt5_env.bat"
SET PYTHONPATH=%PYTHONPATH%;%ROOT%\apps\qgis\python
SET PYCHARM="C:\Program Files\JetBrains\PyCharm Community Edition 2017.2.2\bin\pycharm64.exe"
start "PyCharm aware of QGIS" /B %PYCHARM% %*
View gist:ee408aaae89a9b937559bea6251f064e
string user = @"MULTIPOLYGON (
((497140.111504213 7000067.0051564, 497140.111504239 7000067.00515642,
497108.282321511 6999764.50865007, 496870.11273669 6999736.95241933,
496870.112736702 6999736.95241954, 496870.11273669 6999736.95241954,
496874.346768004 6999813.10375028, 497140.111504239 7000067.00515664,
497140.111504213 7000067.0051564)),
((497171.990745506 7000155.85678491,
497171.990745576 7000155.85678476, 496850.952737626 6999819.44373352,
496816.906830532 6999899.81645738, 496816.9068306 6999899.81645744,
496816.906830532 6999899.8164576, 497150.71415798 7000200.27434632,
@NathanW2
NathanW2 / walkexpressioon.py
Last active Jan 16, 2017
Walk a QgsExpression tree
View walkexpressioon.py
def walk(node):
if node.nodeType() == QgsExpression.ntBinaryOperator:
handle_binary(node)
elif node.nodeType() == QgsExpression.ntUnaryOperator:
print("Unary")
elif node.nodeType() == QgsExpression.ntInOperator:
print("In")
elif node.nodeType() == QgsExpression.ntFunction:
handle_function(node)
elif node.nodeType() == QgsExpression.ntLiteral:
View gist:fc8f1bdf6c54e3480ffd1591a9deb053
ogr2ogr -f "MSSQLSpatial" "MSSQL:DRIVER={SQL Server Native Client 11.0};SERVER=CC-CST-SQL3;DATABASE=GISPROD;TABLE=tech.trees;trusted_authentication=true;" "D:\Temp\Trees.sqlite" -SQL "SELECT * FROM Trees"
View qgis.md

Run with no plugins first

Run OSGeo4w.bat in QGIS install folder run

qgis --noplugins

Still crashing try isloating settings into a new folder

qgis --configpath C:\temp\qgis --optionspath C:\temp\qgis

View qgisorm.py
query = From(iface.activeLayer()) \
.where('"Pit Type" = \'MH\'') \
.limit(10) \
.select("Pit Type", "SURVEY", "CATCHMENT", geometry=True)
query, layer = SQL("SELECT SURVEY, geometry FROM Pits GROUP BY Pit LIMIT 20", name="MyQuery")
query, layer = SQL("SELECT Pit, SURVEY, ST_UNION(ST_Buffer(geometry, 20)) as geometry FROM Pits GROUP BY Pit",
name="Buffers")
View query.sql
SELECT geometry::STGeomFromText('POINT (635641.32 5815631.39 100)', 28355) geom
SELECT CONVERT(varchar(max), geometry::STGeomFromText('POINT (635641.32 5815631.39 100)', 28355).AsBinaryZM(), 2) zmhex
SELECT CONVERT(varchar(max), geometry::STGeomFromText('POINT (635641.32 5815631.39 100)', 28355).STAsBinary(), 2) nozmhex
geom
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
0xC36E0000010D3D0AD7A3F26523418FC2F5D8532F56410000000000005940
zmhex
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
View qgsexpression_texts.cpp
#include "qgsexpression.h"
QHash<QString, QgsExpression::Help> QgsExpression::gFunctionHelpTexts;
void QgsExpression::initFunctionHelp()
{
if( !gFunctionHelpTexts.isEmpty() )
return;
gFunctionHelpTexts.insert( "$area",
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;
You can’t perform that action at this time.