Skip to content

Instantly share code, notes, and snippets.

@johanez
johanez / qgis_poly_nodes_to_pnt.py
Last active March 29, 2016 11:17
Extract polygon nodes from vector layer and creates a point layer with four attribuites: the id of the origin polygon, the node numebr (per polygon), bearing to the follwing point, and distance to follow up node (if in projected CRS!)
##input_polygons=vector
##ref_x=number 5
##ref_y=number 4
##out_pnt_file=output vector
##out_ln_file=output vector
# Extract polygon nodes from polygons in a vector layer
# creates a point layer for the nodes, and a lien layer with
# with lies to the reference point from the closest node and the following node.
# Both out puts have four attributes:
@johanez
johanez / nodes_text.py
Created February 9, 2016 14:49
qgis script to add nodes bearigns and diastances as attribute
##input_polygons=vector
##node_field_name=string
from PyQt4.QtCore import *
from qgis.core import *
# get layer
layer = processing.getObjectFromUri(input_polygons)
progress.setInfo(node_field_name)
@johanez
johanez / rf_parallel.R
Created May 22, 2015 08:25
randomForest CV based variable selection (rfcv) wrapper, that returns the best rf_model and important variable names.
# paralell RF with foreach
# careful: no confusion, err.rate, mse and rsq components
# (as well as the corresponding components in the test compnent, if exist)
rf_parallel <- function(x, y, ntree=500, ncore=4, ...){
require(foreach)
require(randomForest)
# optional parallel backend
if (ncore > 1) {
require(doParallel)
registerDoParallel(ncore)