Skip to content

Instantly share code, notes, and snippets.

View Gustry's full-sized avatar
😇

Étienne Trimaille Gustry

😇
View GitHub Profile
PYTHONUNBUFFERED=1;QGIS_PREFIX_PATH=/home/etienne/dev/app/qgis-master;PYTHONPATH=/usr/lib/python3/dist-packages/
@Gustry
Gustry / algorithm.py
Created April 22, 2021 10:06
Debug vector layer within Processing algo
@staticmethod
def debug_layer(context, layer: QgsMapLayer, name=None):
from qgis.core import QgsProcessingContext
if name:
layer.setName(name)
context.temporaryLayerStore().addMapLayer(layer)
context.addLayerToLoadOnCompletion(
layer.id(),
QgsProcessingContext.LayerDetails(
import sys
from qgis.core import QgsVectorLayer, QgsProject
from qgis.testing import unittest, start_app
start_app()
class TestTest(unittest.TestCase):
@Gustry
Gustry / bash
Created September 9, 2019 08:47
Docker-compose virtualenv
# Installer une version decente de virtualenv
> pip3 install virtualenv virtualenvwrapper
## A copier dans le .bashrc
# export WORKON_HOME=~/.virtualenvs/
# mkdir -p $WORKON_HOME
# export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3
# source "/usr/local/bin/virtualenvwrapper.sh"
#
# S'assurer d'avoir ~/bin dans le path
# coding:utf-8
from qgis.PyQt.QtCore import QUrl
from qgis.PyQt.QtNetwork import QNetworkRequest
from qgis.core import QgsNetworkAccessManager
url = 'http://lizmap.pn971.net/index.php/lizmap/service/?repository=portail&project=portail&SERVICE=WMTS&VERSION=1.0.0&REQUEST=GetCapabilities'
def urlCallFinished(reply):
print(reply.readAll())
https://gis.stackexchange.com/questions/104453/why-result-of-merge-of-multiple-raster-is-so-big
for file in *.jp2; do
[ -e "$file" ] || continue
gdal_translate -of GTiff ${file} -co COMPRESS=JPEG -co bigtiff=yes ${file}.tiff
done
gdal_merge.py -ot Byte -of GTiff -o OUTPUT_block.tif -init "255 255 255" -co tiled=yes -co bigtiff=yes -co compress=jpeg --optfile /tmp/processing_3fad9415054b4e8fa4f0630b609149d9/mergeInputFiles.txt
@Gustry
Gustry / query.sql
Last active July 25, 2018 19:42
SQL get layers without QGIS style
DROP VIEW IF EXISTS liste_des_tables_sans_styles;
CREATE VIEW liste_des_tables_sans_styles AS
SELECT schemaname, tablename
FROM pg_catalog.pg_tables
WHERE schemaname NOT IN ('pg_catalog', 'public', 'information_schema')
EXCEPT
SELECT f_table_schema AS schemaname, f_table_name AS tablename FROM public.layer_styles;
DROP VIEW IF EXISTS liste_des_tables;
CREATE VIEW liste_des_tables AS
/usr/bin/Xvfb :99 -screen 0 1024x768x24 -ac +extension GLX +render -noreset
In Nginx:
fastcgi_param DISPLAY ":99";
@Gustry
Gustry / legend_tree.py
Created October 21, 2015 17:36
Explore the legend tree
layer = iface.legendInterface().currentLayer ()
root = QgsProject.instance().layerTreeRoot()
# Find the layer and set the custom property
layer_node = root.findLayer(layer.id())
old_value = layer_node.customProperty("showFeatureCount")
layer_node.setCustomProperty("showFeatureCount", True)
layer_name = layer_node.layerName()