✅ The verified answer to this question is available below. Our community-reviewed solutions help you understand the material better.
import geopandas as gpdfrom shapely.geometry import LineString, Point
def analyze_network(roads_gdf): endpoints = [] for idx, row in roads_gdf.iterrows(): if isinstance(row.geometry, LineString): endpoints.append(Point(row.geometry.coords[0])) endpoints.append(Point(row.geometry.coords[-1])) points_gdf = gpd.GeoDataFrame(geometry=endpoints) intersections = points_gdf[points_gdf.duplicated(keep=False)] dangling_nodes = points_gdf[~points_gdf.duplicated(keep=False)] return { 'intersections': len(intersections) // 2, 'dangling_nodes': len(dangling_nodes) }
Яку топологічну проблему виявляє цей код?