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
AsgerPetersen / install.sh
Last active January 2, 2016 19:39
MapCache installation på Ubuntu
# 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
# ----------------------------------------------------------------------
"""
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 / Developing-on-QGIS-using-OSGeo4Mac.md
Last active December 14, 2015 08:56
Developing on QGIS using OSGeo4Mac

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

@AsgerPetersen
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
@AsgerPetersen
AsgerPetersen / !wedge_buffers.md
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.

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

@AsgerPetersen
AsgerPetersen / readme.md
Last active June 23, 2020 14:44
PyCharm remote debug of QGIS on OSX

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')
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@AsgerPetersen
AsgerPetersen / pyramid_size.py
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]
@AsgerPetersen
AsgerPetersen / notes.md
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

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.

@AsgerPetersen
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
$BODY$
from scipy.spatial import Voronoi
import numpy
class GeoVoronoi: