Skip to content

Instantly share code, notes, and snippets.

Asger Skovbo Petersen AsgerPetersen

  • Copenhagen, Denmark
View GitHub Profile
@AsgerPetersen
AsgerPetersen / create_voronoi_function.sql
Last active Sep 2, 2019
Fast(er) voronoi polygons in PostGIS
View create_voronoi_function.sql
-- 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
$BODY$
from scipy.spatial import Voronoi
import numpy
class GeoVoronoi:
@AsgerPetersen
AsgerPetersen / notes.md
Last active Jun 22, 2020
Debugging QGIS 3.x python plugins on OSX using VS Code
View notes.md

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

Plugin

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.

View pyramid_size.py
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]
View Wedge buffer.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@AsgerPetersen
AsgerPetersen / readme.md
Last active Jun 23, 2020
PyCharm remote debug of QGIS on OSX
View readme.md

Based heavily on this old guide by TimLinux http://linfiniti.com/2012/09/remote-debugging-qgis-plugins-using-pycharm/

  • 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
sys.path.append('/Applications/PyCharm.app/Contents/debug-eggs/pycharm-debug.egg')
@AsgerPetersen
AsgerPetersen / !wedge_buffers.md
Last active Feb 4, 2016
Wedge buffers in python
View !wedge_buffers.md

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.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF

@AsgerPetersen
AsgerPetersen / lasreader.pxd
Created Oct 6, 2015 — forked from gcasey/lasreader.pxd
Reading LAS file efficiently into numpy using cython
View lasreader.pxd
#%%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
@AsgerPetersen
AsgerPetersen / Developing-on-QGIS-using-OSGeo4Mac.md
Last active Dec 14, 2015
Developing on QGIS using OSGeo4Mac
View Developing-on-QGIS-using-OSGeo4Mac.md

Note: This page has been copied from https://github.com/OSGeo/homebrew-osgeo4mac/wiki/Developing-on-QGIS-using-OSGeo4Mac and includes my notes. The original text is written by @dakcarto.

Developing on QGIS using OSGeo4Mac

In addition to using this tap to install a QGIS stable formula, you can also use it to fully set up a development environment for an externally built QGIS from a clone of the current development (master) branch of the source code tree.

Note: This setup, though heavily tested, is currently experimental and may change. A more stable and time-tested setup is outlined in the QGIS INSTALL document.

Development Tools

View zonal_stats.py
"""
Zonal Statistics
Vector-Raster Analysis
Copyright 2013 Matthew Perry
Changes by AsgerPetersen:
- Use band nodata value if user does not override it
- Allow calculating statistics for all geometry types
- Allow buffer to be applied before calculation
@AsgerPetersen
AsgerPetersen / install.sh
Last active Jan 2, 2016
MapCache installation på Ubuntu
View install.sh
# Se https://code.google.com/p/ala-citizenscience/wiki/MapServerAndMapCacheSetup
# Se http://mapserver.org/trunk/mapcache/install.html#linux-instructions
# Se https://github.com/mapserver/mapcache/blob/master/INSTALL
# ubuntugis er ikke nødvendig, hvis kun mapcache skal installeres
# sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable
sudo apt-get update
# ----------------------------------------------------------------------
You can’t perform that action at this time.