Skip to content

Instantly share code, notes, and snippets.

View moosetraveller's full-sized avatar

Thomas Zuberbühler moosetraveller

View GitHub Profile
@moosetraveller
moosetraveller / qgis-map-to-tiff.md
Last active March 3, 2022 01:55
Convert QGIS Map to TIFF File

Convert QGIS Map to TIFF File

Using QgsMapRendererParallelJob

  1. Iterate over shape files in INPUT_FOLDER
  2. Apply style file
  3. Generate TIFF file using QgsMapRendererParallelJob
import os
@moosetraveller
moosetraveller / leaflet-map-wfs-airports.html
Created March 6, 2022 17:42
Leaflet Map using WFS and GeoServer
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Leaflet Map using WFS and GeoServer</title>
<script src="https://unpkg.com/rxjs@^7/dist/bundles/rxjs.umd.min.js"></script>
@moosetraveller
moosetraveller / antimeridian-polygon-split.py
Last active June 25, 2024 09:59
QGIS Processing Tool splitting Polygons along Antimeridian
"""
The following QGIS tool corrects polygons that are overlapping
the antimeridian by creating multipolygons with two parts on
both sides of the antimeridian.
Limitations:
- The geometry must be WGS 84 (EPSG:4326).
- Polygons must not have holes.
Dependencies:
@moosetraveller
moosetraveller / date_time_widget_example.py
Created June 8, 2022 02:48
Create DateTime widget for QGIS Processing Tool
from qgis.PyQt.QtCore import (
QCoreApplication,
QDateTime,
)
from processing.gui.wrappers import WidgetWrapper
from qgis.gui import QgsDateTimeEdit
from qgis.core import (
Qgis,
This gist I write, because I couldn't find step by step instructions
how to install and start postgresql locally and not globally in the
operating system (which would require sudo).
I hope, this will help especially people new to postgresql!
####################################
# create conda environment
####################################
@moosetraveller
moosetraveller / arcgis-py-install-fails.md
Last active July 19, 2022 19:39
ArcGIS API for Python installation fails

If you receive the error shown below (or similar) when installing the arcgis package with pip, then you need to install the system component libkrb5-dev:

  • Run sudo apt install libkrb5-dev
  • Rerun pip install arcgis
Collecting gssapi
  Using cached gssapi-1.7.3.tar.gz (1.3 MB)
  Preparing metadata (setup.py) ... error
  error: subprocess-exited-with-error
@moosetraveller
moosetraveller / flask-celery.md
Last active August 17, 2022 14:33
Flask with Celery

Flask with Celery

Files

tasks/long_running.py

from app import celery

__all__ = ["execute_print_job"]
@moosetraveller
moosetraveller / install-pyenv.md
Last active September 1, 2022 13:27
Install Python with PyEnv

Install Python with PyEnv

  1. Install PyEnv (see also here: https://github.com/pyenv/pyenv-installer)
    • Requires GIT
    • Install with curl https://pyenv.run | bash
  2. Add following lines to vi ~/.bashrc:
export PYENV_ROOT="$HOME/.pyenv"
command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"
@moosetraveller
moosetraveller / upload-file.md
Created August 17, 2022 15:01
Upload a File with Fetch API

Upload a File with Fetch API

async function upload() {

    const input = document.querySelector('input[type="file"]');

    const data = new FormData();
    data.append("file", input.files[0]);
@moosetraveller
moosetraveller / flask-sqlalchemy-sqlite.md
Last active September 4, 2022 21:45
Load SQLite Extension with SQLAlchemy (in Flask)

Load SQLite Extension with SQLAlchemy (in Flask)

Files

app/db.py

from flask_sqlalchemy import SQLAlchemy

from sqlalchemy import event