def test_snap_street_network_edge(self): snapped = mm.snap_street_network_edge(self.df_streets, self.df_buildings, 20, self.df_tessellation, 70) snapped_nonedge = mm.snap_street_network_edge(self.df_streets, self.df_buildings, 20) snapped_edge = mm.snap_street_network_edge( self.df_streets, self.df_buildings, 20, tolerance_edge=70, edge=mm.buffered_limit(self.df_buildings, buffer=50), ) assert sum(snapped.geometry.length) == 5980.041004739525 assert sum(snapped_edge.geometry.length) == 5980.718889937014 assert sum(snapped_nonedge.geometry.length) < 5980.041004739525
def time_snap_street_network_edge(self): mm.snap_street_network_edge(self.df_streets, self.df_buildings, 20, self.df_tessellation, 70)
import geopandas as gpd import momepy as mm tess = gpd.read_file('files/prg.gpkg', layer='queen') blg = gpd.read_file('files/prg.gpkg', layer='buildings') streets = gpd.read_file('files/streets.gpkg', layer='streets') streets['nID'] = mm.unique_id(streets) blg['nID'] = mm.get_network_id(blg, streets, 'uID', 'nID', 150) tess = tess.merge(blg[['uID', 'nID']], on='uID', how='left') snapped = mm.snap_street_network_edge(streets, blg, 20, tess, 120) blocks, blg['bID'], tess['bID'] = mm.blocks(tess, snapped, blg, 'bID', 'uID') tess.to_file('files/elements.gpkg', layer='tessellation', driver='GPKG') blg.to_file('files/elements.gpkg', layer='buildings', driver='GPKG') blocks.to_file('files/elements.gpkg', layer='blocks', driver='GPKG') streets.to_file('files/elements.gpkg', layer='streets', driver='GPKG')
def test_snap_street_network_edge(self): snapped = mm.snap_street_network_edge(self.df_streets, self.df_buildings, self.df_tessellation, 20, 70) assert sum(snapped.geometry.length) == 5980.041004739525