def setup(self): test_file_path = mm.datasets.get_path("bubenec") self.df_buildings = gpd.read_file(test_file_path, layer="buildings") self.df_streets = gpd.read_file(test_file_path, layer="streets") self.df_tessellation = gpd.read_file(test_file_path, layer="tessellation") self.df_streets["nID"] = mm.unique_id(self.df_streets) self.df_buildings["height"] = np.linspace(10.0, 30.0, 144) self.df_tessellation["area"] = self.df_tessellation.geometry.area self.df_buildings["area"] = self.df_buildings.geometry.area self.df_buildings["fl_area"] = mm.FloorArea(self.df_buildings, "height").series self.df_buildings["nID"] = mm.get_network_id(self.df_buildings, self.df_streets, "nID") blocks = mm.Blocks(self.df_tessellation, self.df_streets, self.df_buildings, "bID", "uID") self.blocks = blocks.blocks self.df_buildings["bID"] = blocks.buildings_id self.df_tessellation["bID"] = blocks.tessellation_id self.swb = Queen.from_dataframe(self.df_buildings) self.sw5 = mm.sw_high(k=5, gdf=self.df_tessellation, ids="uID") self.sw3 = mm.sw_high(k=3, gdf=self.df_tessellation, ids="uID") self.sws = mm.sw_high(k=2, gdf=self.df_streets) nx = mm.gdf_to_nx(self.df_streets) nx = mm.node_degree(nx) self.nodes, self.edges, W = mm.nx_to_gdf(nx, spatial_weights=True) self.swn = mm.sw_high(k=3, weights=W)
def setup_method(self): test_file_path = mm.datasets.get_path("bubenec") self.df_streets = gpd.read_file(test_file_path, layer="streets") self.network = mm.gdf_to_nx(self.df_streets) self.network = mm.node_degree(self.network) self.dual = mm.gdf_to_nx(self.df_streets, approach="dual")
def test_NodeDensity(self): nx = mm.gdf_to_nx(self.df_streets) nx = mm.node_degree(nx) nodes, edges, W = mm.nx_to_gdf(nx, spatial_weights=True) sw = mm.sw_high(k=3, weights=W) density = mm.NodeDensity(nodes, edges, sw).series weighted = mm.NodeDensity( nodes, edges, sw, weighted=True, node_degree="degree" ).series array = mm.NodeDensity(nodes, edges, W).series assert density.mean() == 0.012690163074599968 assert weighted.mean() == 0.023207675994368446 assert array.mean() == 0.008554067995928158
def test_node_degree(self): deg1 = mm.node_degree(graph=self.network) assert deg1.nodes[(1603650.450422848, 6464368.600601688)]["degree"] == 4
def time_node_degree(self): mm.node_degree(graph=self.network)
def test_node_degree(self): graph = mm.gdf_to_nx(self.df_streets) deg1 = mm.node_degree(graph=graph) assert deg1.nodes[(1603650.450422848, 6464368.600601688)]['degree'] == 4
def setup_method(self): test_file_path = mm.datasets.get_path('bubenec') self.df_streets = gpd.read_file(test_file_path, layer='streets') self.network = mm.gdf_to_nx(self.df_streets) self.network = mm.node_degree(self.network)
import momepy as mm import geopandas as gpd import libpysal streets = gpd.read_file("files/elements.gpkg", layer="streets") graph = mm.gdf_to_nx(streets) print("node degree") graph = mm.node_degree(graph) print("subgraph") graph = mm.subgraph( graph, radius=5, meshedness=True, cds_length=False, mode="sum", degree="degree", length="mm_len", mean_node_degree=False, proportion={ 0: True, 3: True, 4: True }, cyclomatic=False, edge_node_ratio=False, gamma=False, local_closeness=True, closeness_distance="mm_len",