logo

Crowdly

Browser

Add to Chrome

import geopandas as gpd from shapely.geometry import LineString, Point def a...

✅ The verified answer to this question is available below. Our community-reviewed solutions help you understand the material better.

import geopandas as gpd

from 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)

    }

Яку топологічну проблему виявляє цей код?

0%
0%
0%
0%
More questions like this

Want instant access to all verified answers on moodle.chnu.edu.ua?

Get Unlimited Answers To Exam Questions - Install Crowdly Extension Now!

Browser

Add to Chrome