Skip to content

Instantly share code, notes, and snippets.

@mdouchin
mdouchin / set_layer_filter_by_extent.py
Created March 29, 2024 16:14
QGIS - Set layers substring filter with WHERE clause depending on map canvas extent and intersected polygons
class filterLayersFromExtent:
polygon_layer = {
'name': 'polygons',
'field': 'code',
'layer': None
}
target_layers = [
{
'name': 'observation',
@mdouchin
mdouchin / standalone_processing_runner.py
Last active July 13, 2021 13:32
Allows to run a QGIS processing algorithm from the CLI. Only usefull when qgis_process is not installed
#!/usr/bin/env python3
import os
import sys
import json
# variables
pg_service_file = '/etc/postgresql-common/pg_service.conf'
# Initialize needed paths
# to be able to load processing.core.Processing
@mdouchin
mdouchin / AuditQGISProjects.py
Last active October 6, 2021 08:34
Audit the QGIS projects found in a directory and it sub-directories, and export a CSV file containing the fetched information
# -*- coding: utf-8 -*-
"""
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************
@mdouchin
mdouchin / liz.sh
Last active January 13, 2024 15:25
PostgreSQL/PostGIS in Termux: help script to install and manage PostgreSQL & PostGIS
#!/usr/bin/env bash
COMMAND="$1"
shift
function liz_storage() {
echo "Storage - configure termux setup storage"
termux-setup-storage
}
@mdouchin
mdouchin / gobs_openapi.json
Last active July 7, 2020 12:02
G-Obs OpenAPI
{
"openapi": "3.0.1",
"info": {
"title": "G-Obs API",
"description": "G-obs API as OpenAPI Rest API",
"termsOfService": "",
"contact": {
"email": "info@3liz.com"
},
"license": {
@mdouchin
mdouchin / replace_geolocation_autocenter_button.js
Created June 16, 2020 05:29
Lizmap geolocation - Control GPS auto-center duration
lizMap.events.on({
'uicreated': function(e) {
// Re-Center frequency in ms
var autoCenterTimeout = 10000;
// Do not edit after this line
var autoCenterStatus = false;
var autoCenterTm = null;
@mdouchin
mdouchin / POSTGIS_add_multiple_fields_to_a_table.sql
Last active June 18, 2019 12:27
POSTGIS - Function to add multiple fields to a given table
-- Fonction de création des champs nécessaires sur les tables
-- DROP FUNCTION IF EXISTS public.ajout_champs_dynamiques(text, text, text);
CREATE OR REPLACE FUNCTION public.ajout_champs_dynamiques(schemaname text, tablename text, colonnes text)
RETURNS INTEGER AS
$limite$
DECLARE
colonnes_a text[];
sql_text text;
t text;
BEGIN
@mdouchin
mdouchin / qgis_deploy_install_upgrade_ltr.ps1
Created June 11, 2019 10:36 — forked from Guts/qgis_deploy_install_upgrade_ltr.ps1
Use OSGeo4W installer command-line abilities to provide a real-life example like downloading and installing QGIS LTR full meta-package
#Requires -RunAsAdministrator
<#
.Synopsis
Download the OSGeo4W installer then download and install QGIS LTR (through the 'full' meta-package).
.DESCRIPTION
This script will:
1. change the current directory to the user downloads folder
2. download the OSGeo4W installer
3. launch it passing command-line parameters to DOWNLOAD packages required to QGIS LTR FULL
# QGIS 3 (compatible with 2.18) python code to count features
# for each unique value of chosen fields
#
# Copy paste in your python console
# You need to change the "fields" variable below
# And select the layer in QGIS legend before running it
#
# The output memory layer attribute table would be like
# fieldname fieldvalue count
# menace EN 19355

Use MSSQL layers with QGIS 2.18 in Debian Stretch 9.6

Prerequisites

  • Install Microsof repositories
curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -
curl https://packages.microsoft.com/config/debian/9/prod.list  > /etc/apt/sources.list.d/mssql-release.list