Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/source/mwe.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.14.7"
"version": "3.14.8"
}
},
"nbformat": 4,
Expand Down
4 changes: 2 additions & 2 deletions docs/source/usage_01_gap_identification.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"tags": []
},
"source": [
"**Parameters covered**: `numgaps`, `radius`, `mingap`, `maxgap`"
"**Parameters covered**: `numgaps`, `settings.radius`, `mingap`, `maxgap`"
]
},
{
Expand Down Expand Up @@ -92,7 +92,7 @@
"source": [
"FixBikeNet is based on the idea that any shortest path between two nodes on an existing bicycle network, where the entire path goes through the non-bicycle network, is a potential gap. Out of these potentially millions of gaps in a city, FixBikeNet identifies those that are most important to close in terms of providing the most cycled meters (per gap meter). It ranks the identified gaps and selects the top `numgaps` - the first parameter for running FixBikeNet. The ranking happens through betweenness centrality, a proxy for cyclist flow. This measure assumes that cyclists move from each intersection to each other intersection in the city.\n",
"\n",
"The assumption of such a global all-to-all flow is relaxed in FixBikeNet to only consider local betweenness flows within a `radius` - the second parameter. This relaxation is done for several reasons: \n",
"The assumption of such a global all-to-all flow is relaxed in FixBikeNet to only consider local betweenness flows within a `settings.radius` (that is loaded from `fbn.settings`). This relaxation is done for several reasons: \n",
"1) Typical cyclists are usually not traversing the whole city\n",
"2) global betweenness is biased towards the city center while local betweenness allows identifying gaps on neighborhood levels\n",
"3) calculations are much more effective, especially for large cities."
Expand Down
2 changes: 1 addition & 1 deletion examples/development.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
# },
# )

fbn.settings.radius = 1000

fbn.fixbikenet(
city_query="Frederiksberg Municipality",
radius = 1000,
mingap = 0,
maxgap = 100,
numgaps = 20,
Expand Down
35 changes: 21 additions & 14 deletions fixbikenet/fixbikenet.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@

def fixbikenet(
city_query,
radius = 2500,
mingap = 20,
maxgap = 800,
numgaps = 50,
Expand All @@ -56,26 +55,34 @@ def fixbikenet(
export_plot=False,
import_files={},
):
"""Find gaps in bicycle networks and return the `numgaps` that are the most important to fill.
"""Find gaps in bicycle networks and return the `numgaps` that are the most
important to fill.

Parameters
----------
city_query : str
name of the city that the analysis should be performed on
radius : int, default 2500
cut-off length for computation of local betweenness centrality, in meters
Name of the city that the analysis should be performed on.
mingap : int, default 20
Minimum distance between node pairs to be considered as a potential gap, in meters.
Minimum distance between node pairs to be considered as a potential
gap, in meters.
maxgap : int, default 800
maximum distance between node pairs to be considered as a potential gap, in meters
Maximum distance between node pairs to be considered as a potential
gap, in meters.
numgaps : int, default 50
Number of gaps to find.
export_data : bool, optional, default True
If set to True, data will be saved to a file. The filename is [slug].gpkg, where slug is a string id made out of city_name
export_data : bool, default True
If set to True, data will be saved to a file. The filename is
[slug].[settings.export_file_format], where slug is a string id made
out of `city_query` (or `city_id` if set).
city_id : str | None, default None
If set, the slugified city_id is used in the filename of the data export. For example, a city_id "Athens" will slugify into "athens" in filenames. If set to None, the slugified city_query is used in the filename of the data export. It is useful to set a city_id for cities where the city_query is not the city name, for example to set for a city_query "Municipality of Athens" the city_id to "Athens".
If set, the slugified `city_id` is used in the filename of the data
export. For example, a `city_id` "Athens" will slugify into "athens"
in filenames. If set to None, the slugified `city_query` is used in the
filename of the data export. It is useful to set a `city_id` for cities
where the `city_query` is not the city name, for example to set for a
`city_query` "Municipality of Athens" the `city_id` to "Athens".
export_plot : bool, optional, default False
If set to True, plot will be saved to a file
If set to True, plot will be saved to a file.
import_files: dict, default {}
The following key:value entries can be set:

Expand Down Expand Up @@ -104,7 +111,7 @@ def fixbikenet(
Returns
-------
gaps_ordered : geopandas.geodataframe.GeoDataFrame
ordered geodataframe with the `numgaps` most important gaps to fill
Ordered geodataframe with the `numgaps` most important gaps to fill.

References
----------
Expand All @@ -115,7 +122,7 @@ def fixbikenet(
starttime = time.time()
np.random.seed(settings.random_seed) # Set random number generator seed for reproducibility
setting_was_auto = _validate_settings()
import_files = _validate_parameters(city_query, radius, mingap, maxgap, export_data, import_files)
import_files = _validate_parameters(city_query, mingap, maxgap, export_data, import_files)
_print_header(city_query)

### Import data files
Expand Down Expand Up @@ -187,7 +194,7 @@ def fixbikenet(
found_gaps, found_gaps_nsp = find_actual_gaps(G, potential_gaps, mingap)

# calculating local betweenness score dependent on radius
ebc = compute_local_betweenness_centrality(G, nodes_gdf, radius)
ebc = compute_local_betweenness_centrality(G, nodes_gdf)

G_lengths = nx.get_edge_attributes(G, "length")
nx.set_edge_attributes(G, G_lengths, "distance")
Expand Down
Loading
Loading