Artelys / geonetworkx

Python tools for geographic graphs
MIT License
34 stars 4 forks source link

Problem in isochrone_polygon_with_alpha_shape #4

Open sblandin2018 opened 3 years ago

sblandin2018 commented 3 years ago

Hello,

I tried to use isochrone_polygon_with_alpha_shape method but I get a TypeError like the following:

~\AppData\Local\Continuum\anaconda3\envs\ultra-np\lib\site-packages\geonetworkx\tools\isochrones.py in isochrone_polygon_with_alpha_shape(graph, source, limit, weight, alpha_quantile, remove_holes, tolerance)
    204     ego_graph = gnx.extended_ego_graph(graph, source, limit, distance=weight)
    205     edge_as_lines = ego_graph.get_edges_as_line_series()
--> 206     discretized_lines, _ = gnx.discretize_lines(edge_as_lines)
    207     alpha_shape = get_alpha_shape_polygon(discretized_lines, alpha_quantile)
    208     alpha_shape = alpha_shape.buffer(tolerance)

TypeError: discretize_lines() missing 1 required positional argument: 'discretization_tol'

You can reproduce the issue with the following code:

import geonetworkx as gnx
import osmnx as ox
g = ox.get_digraph(ox.graph_from_bbox(45.64890, 45.58723, 8.88880, 8.80244))
gg = gnx.read_geograph_with_coordinates_attributes(g)
gnx.fill_length_attribute(gg)
iso_poly = gnx.isochrone_polygon_with_alpha_shape(gg, 2321989260, 500)

It seems that discretize_lines function needs an additional discretization_tol parameter to work.

adolmajian commented 2 years ago

Any progress on this issue?

Calvinssmao commented 1 year ago

I solve this problem by adding some code into geonetworkx.tools.isochrones.py on line 206-207.

discretization_tol = gnx.readwrite.graph_edges_to_gdf(graph)['length'].max()
discretized_lines, _ = gnx.discretize_lines(edge_as_lines, discretization_tol)