def test_get_channel2(self): """ Test crea los canales hasta outlet para todas las cabeceras (sin mouth) """ files = ["small25", "jebja30", "tunez"] for file in files: net = Network("data/in/{}_net.dat".format(file)) heads = net.get_stream_poi(kind="heads", coords="XY") for head in heads: canal = net.get_channel(head) # Verificamos que canal se ha creado bien self.assertEqual(isinstance(canal, Channel), True)
geom_type = layer.GetGeomType() lydef = layer.GetLayerDefn() id_fld = lydef.GetFieldIndex(idfield) points = [] for feat in layer: geom = feat.GetGeometryRef() if geom.GetGeometryCount() > 1: continue head = geom.GetPoint(0) mouth = geom.GetPoint(geom.GetPointCount() - 1) points.append([head, mouth]) canales = [] for canal in points: head = canal[0] mouth = canal[1] canales.append(net.get_channel(head, mouth)) import matplotlib.pyplot as plt canal = canales[0] fig = plt.figure() ax = fig.add_subplot(111) dir(canal) canal.get_xy() for canal in canales: xy = canal.get_xy() ax.plot(xy[:, 0], xy[:, 1])
from topopy import Network, Channel, Flow, BNetwork import ogr import numpy as np import matplotlib.pyplot as plt fd = Flow("../data/in/jebja30_fd.tif") net = Network("../data/in/jebja30_net.dat") cuencas = fd.get_drainage_basins() bnet1 = BNetwork(net, cuencas, None, 3) bnet2 = BNetwork(net, cuencas, None, 10) shp_path = "../data/out/canales_basin.shp" bnet1.export_to_shp(shp_path, True) dataset = ogr.Open(shp_path) layer = dataset.GetLayer(0) canales = [] for n in range(layer.GetFeatureCount()): feat = layer.GetFeature(n) geom = feat.GetGeometryRef() head = geom.GetPoint(0) mouth = geom.GetPoint(geom.GetPointCount() - 1) canal = net.get_channel(head, mouth) canales.append(canal) canales = np.array(canales) np.save("../data/out/canales-b3_jebja30.npy", canales)
import matplotlib.pyplot as plt import numpy as np from profiler import TProfile # Test longitudinal profile # Load profiles (TProfile) prof_path = "/Users/vicen/Desktop/genil_profiler/scripts/files/graph_profiles.npy" perfiles = np.load(prof_path, allow_pickle=True) perfil = perfiles[0] # Load channels (Channel) net = Network("/Users/vicen/Desktop/genil_profiler/gisdata/genil_net.dat") net.calculate_gradients(20, "slp") heads = extract_points("/Users/vicen/Desktop/genil_profiler/gisdata/heads.shp", "id") canal = net.get_channel(heads[0]) fig, ax = plt.subplots() # di = perfil.get_l() # zi = perfil.get_z() # ax.plot(di, zi, c="b") # di2 = canal.get_d() # zi2 = canal.get_z() # ax.plot(di2, zi2, c="r") slopes = perfil.get_slope() areas = perfil.get_area() ax.plot(areas, slopes, "b.", mew=0.5)