def test_get_node_id(self): nx = mm.gdf_to_nx(self.df_streets) nodes, edges = mm.nx_to_gdf(nx) self.df_buildings["nID"] = mm.get_network_id(self.df_buildings, self.df_streets, "nID") ids = mm.get_node_id(self.df_buildings, nodes, edges, "nodeID", "nID") assert not ids.isna().any() convex_hull = edges.unary_union.convex_hull enclosures = mm.enclosures(edges, limit=gpd.GeoSeries([convex_hull])) enclosed_tess = mm.Tessellation(self.df_buildings, unique_id="uID", enclosures=enclosures).tessellation links = mm.get_network_ratio(enclosed_tess, edges) enclosed_tess[links.columns] = links ids = mm.get_node_id( enclosed_tess, nodes, edges, node_id="nodeID", edge_keys="edgeID_keys", edge_values="edgeID_values", ) assert not ids.isna().any()
def test_get_node_id(self): nx = mm.gdf_to_nx(self.df_streets) nodes, edges = mm.nx_to_gdf(nx) self.df_buildings["nID"] = mm.get_network_id( self.df_buildings, self.df_streets, "nID" ) ids = mm.get_node_id(self.df_buildings, nodes, edges, "nodeID", "nID") assert not ids.isna().any()
def time_get_node_id(self): mm.get_node_id(self.df_buildings, self.nodes, self.edges, "nodeID", "nID")
"/Users/martin/Dropbox/Academia/Data/Geo/Prague/Redo/elements.gpkg", layer="edges", driver="GPKG", ) # tess.to_file("/Users/martin/Dropbox/Academia/Data/Geo/Prague/Redo/elements.gpkg", layer="tessellation", driver="GPKG") # blg.to_file("/Users/martin/Dropbox/Academia/Data/Geo/Prague/Redo/elements.gpkg", layer="buildings", driver="GPKG") try: blg.drop(columns=["nodeID"], inplace=True) except Exception: print("no nodeID") try: tess.drop(columns=["nodeID"], inplace=True) except Exception: print("no nodeID") blg["nodeID"] = mm.get_node_id(blg, nodes, edges, "nodeID", "nID") tess = tess.merge(blg[["uID", "nodeID"]], on="uID", how="left") nodes_w3 = mm.sw_high(k=3, weights=sw) nodes_w3.neighbors = { int(k): [int(i) for i in v] for k, v in nodes_w3.neighbors.items() } nodes["lddRea"] = mm.reached(nodes, tess, "nodeID", "nodeID", nodes_w3) nodes["lddARe"] = mm.reached( nodes, tess, "nodeID", "nodeID", nodes_w3, mode="sum", values="sdcAre" ) nodes["sddAre"] = mm.reached( nodes, tess, "nodeID", "nodeID", mode="sum", values="sdcAre" )