out_pos = (sum_arr == 0) & w elif kind == 'confluences': sum_arr = np.asarray(np.sum(sp_arr, 0)).ravel() out_pos = sum_arr > 1 elif kind == 'outlets': sum_arr = np.asarray(np.sum(sp_arr, 1)).ravel() out_pos = (sum_arr == 0) & w out_pos = out_pos.reshape(fd._dims) row, col = np.where(out_pos) return row, col dem = DEM("../data/tunez.tif") fd = Flow() fd.load_gtiff("../data/tunez_fd.tif") fig, ax = plt.subplots() dem.plot(ax) streams = fd.get_network(1000) streams.plot(ax) # Heads row, col = get_stream_poi(fd, 1000, 'heads') ax.plot(col, row, "ro") # # Confluences row, col = get_stream_poi(fd, 1000, 'confluences') ax.plot(col, row, "bs")
# -*- coding: utf-8 -*- """ Created on Fri Jan 26 17:53:42 2018 @author: vicen """ import sys sys.path.append("../../") from topopy import Flow, Grid import numpy as np from scipy.sparse import csc_matrix import matplotlib.pyplot as plt fd = Flow() fd.load_gtiff("../data/in/fd_tunez.tif") threshold = 1000 fac = fd.get_flow_accumulation(nodata=False, asgrid=False) w = fac > threshold w = w.ravel() I = w[fd._ix] ix = fd._ix[I] ixc = fd._ixc[I] ixcix = np.zeros(fd._ncells, np.int) ixcix[fd._ix] = np.arange(len(fd._ix)) ixcix[ix] = np.arange(len(ix)) x = 507194.338