Skip to content

Instantly share code, notes, and snippets.

View NathanW2's full-sized avatar

Nathan Woodrow NathanW2

View GitHub Profile
CALL "C:\Program Files\QGIS 3.4\bin\o4w_env.bat"
CALL "C:\Program Files\QGIS 3.4\bin\py3_env.bat"
CALL "C:\Program Files\QGIS 3.4\bin\qt5_env.bat"
SET PYTHONPATH=C:\Program Files\QGIS 3.4\apps\qgis-ltr\python
cmd
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
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% %*
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 January 16, 2017 13:24
Walk a QgsExpression tree
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:
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"
@NathanW2
NathanW2 / qgis.md
Last active November 8, 2016 14:25

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

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")
@NathanW2
NathanW2 / query.sql
Last active September 27, 2016 02:50
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
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
#include "qgsexpression.h"
QHash<QString, QgsExpression::Help> QgsExpression::gFunctionHelpTexts;
void QgsExpression::initFunctionHelp()
{
if( !gFunctionHelpTexts.isEmpty() )
return;
gFunctionHelpTexts.insert( "$area",