Skip to content

Instantly share code, notes, and snippets.

Avatar

Nathan Woodrow NathanW2

View GitHub Profile
View qgis-cmd.bat
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
View gist:4029400
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)
View gist:4577289
import os, arcpy
#create blank text file
with open("C:\\Temp\\GISlayers.txt", "w") as txt:
for root, dirs, files in os.walk("C:\\Temp\\temp"):
for f in files:
#look for shapefiles
if f.endswith('.shp') or f.endswith('.lyr') or
f.endswith('.img'):
desc = arcpy.Describe(root + "\\" + f)
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% %*
@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 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

You can’t perform that action at this time.