Skip to content

Instantly share code, notes, and snippets.

View jfbourdon's full-sized avatar

Jean-François Bourdon jfbourdon

View GitHub Profile
@jfbourdon
jfbourdon / stream_priority.py
Created May 17, 2022 18:40
Establish stream priority in network from line direction
from qgis.PyQt.QtCore import QCoreApplication
from qgis.core import *
from qgis.utils import pluginMetadata
from PyQt5.QtCore import *
import processing
from processing.core.Processing import Processing
from qgis.analysis import QgsNativeAlgorithms
import os
from collections import deque
@jfbourdon
jfbourdon / zvalue_from_index.py
Created October 19, 2018 18:37
zvalue_from_index for KRSTN
def _zvalue_from_index(arr, ind):
"""private helper function to work around the limitation of np.choose() by employing np.take()
arr has to be a 3D array
ind has to be a 2D array containing values for z-indicies to take from arr
See: http://stackoverflow.com/a/32091712/4169585
This is faster and more memory efficient than using the ogrid based solution with fancy indexing.
"""
# get number of rows and columns
_,nR,nC = arr.shape