Skip to content

Instantly share code, notes, and snippets.

View AsgerPetersen's full-sized avatar

Asger Skovbo Petersen AsgerPetersen

  • Copenhagen, Denmark
View GitHub Profile
AsgerPetersen / Debugging QGIS on OSX using VSCode and
Last active April 30, 2024 12:55
Debugging QGIS python plugins on OSX using VSCode

Debugging QGIS python plugins using VSCode on OSX

This is how I debug QGIS using VSCode on OSX. Previously I used this approach. But since then ptvsd was deprecated and I also needed to install python modules backed by native C code. This is much easier to do in a conda based environment (actually, I didn't find a way to make it work with the official QGIS installer :-)).

Get QGIS running in a conda env

Follow this description to get QGIS running in conda.

Install debugpy

ptvsd is superseded by debugpy.


AsgerPetersen / QGIS on OSX with
Last active July 5, 2024 17:29
QGIS using conda on OSX
AsgerPetersen /
Last active October 19, 2020 13:15
Test rasterstats with or without boundless reading
AsgerPetersen / create_voronoi_function.sql
Last active November 17, 2021 15:41
Fast(er) voronoi polygons in PostGIS
-- plpython needs to be enabled. Furthermore scipy needs to be installed in the python used.
-- CREATE LANGUAGE plpythonu;
CREATE OR REPLACE FUNCTION septima.voronoi(geom geometry, boundingpointdistance double precision)
RETURNS SETOF geometry_dump AS
from scipy.spatial import Voronoi
import numpy
class GeoVoronoi:
AsgerPetersen /
Last active April 27, 2024 13:27
Debugging QGIS 3.x python plugins on OSX using VS Code

Debugging QGIS 3.x python plugins on OSX using VS Code


In QGIS install the plugin debugvs.

Python dependencies

The debugvs plugin needs the python module ptvsd to function. This module is not installed by default.

In principle you just pip install ptvsd in the python interpreter used by QGIS.

AsgerPetersen /
Created November 13, 2017 08:23
Size of tile pyramid
from math import log, ceil, sqrt
# Gennemsnitlig stoerrelse af en tile. 25kB passer nogenlunde med ortofoto
size_per_tile = 25 * 1024 # 25kB
# --------GSTs standard skema ---------------
# Koordinater paa tilet omraade (xmin, ymin, xmax, ymax)
#bbox = [120000, 5900000, 1000000, 6500000]
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
AsgerPetersen /
Last active June 23, 2020 14:44
PyCharm remote debug of QGIS on OSX

Based heavily on this old guide by TimLinux

  • In PyCharm click menu "Run -> Edit Configurations" (Or click Edit Configurations in the dropdown in the toolbar)
  • Click the plus to add a new "Python Remote Debug" config
  • Name the config. Use port 53100 (Could probably be any high port)
  • Add to the python code:
import sys
AsgerPetersen / !
Last active February 4, 2016 13:31
Wedge buffers in python

Wedge buffers in python

Copyright (c) 2016, Asger Sigurd Skovbo Petersen

Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.


AsgerPetersen / lasreader.pxd
Created October 6, 2015 12:01 — forked from gcasey/lasreader.pxd
Reading LAS file efficiently into numpy using cython
#%%cython -I/usr/local/include -L/usr/local/lib -llas_c
# Created by Casey Goodlett
cimport cython
import numpy as np
cimport numpy as np
import liblas
DTYPE = np.float64
ctypedef np.float64_t DTYPE_t