diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml
index 8bd1d31..c262c0a 100644
--- a/.github/workflows/docs.yml
+++ b/.github/workflows/docs.yml
@@ -41,14 +41,6 @@ jobs:
run:
shell: bash -el {0}
steps:
- - name: Check if GHSL site is under maintenance
- run: |
- content=$(curl -s https://jeodpp.jrc.ec.europa.eu/ftp/jrc-opendata/GHSL/)
- if echo "$content" | grep -q "Under Maintenance"; then
- echo "GHSL site is under maintenance. Exiting."
- exit 1
- fi
-
- name: Check out Git repository
uses: actions/checkout@v6
@@ -66,10 +58,10 @@ jobs:
- name: Add Notebook Kernel
run: python -m ipykernel install --user --name growbikenet --display-name "Python (growbikenet)"
- - name: Generating .rst files
- run: sphinx-apidoc -o docs/api/ growbikenet/
+ # - name: Generating .rst files
+ # run: sphinx-apidoc -o docs/api/ growbikenet/
- name: Generating html
- run: sphinx-build docs public -b dirhtml
+ run: sphinx-build docs/source/ public -b dirhtml
- name: Setup Pages
uses: actions/configure-pages@v5
diff --git a/README.md b/README.md
index 9020913..16d56ac 100644
--- a/README.md
+++ b/README.md
@@ -49,6 +49,6 @@ Find more information in our docs: [https://bikenetkit.github.io/GrowBikeNet/](h
## Supported by
Development of BikeNetKit/GrowBikeNet was supported by the Innovation Fund Denmark and the EU HORIZON grant JUST STREETS.
-[](https://innovationsfonden.dk/en) [](https://commission.europa.eu/index_en) [](https://www.just-streets.eu/)
+[](https://innovationsfonden.dk/en) [](https://commission.europa.eu/index_en) [](https://www.just-streets.eu/)
diff --git a/docs/Makefile b/docs/Makefile
index d4bb2cb..92dd33a 100644
--- a/docs/Makefile
+++ b/docs/Makefile
@@ -5,7 +5,7 @@
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
-SOURCEDIR = .
+SOURCEDIR = source
BUILDDIR = _build
# Put it first so that "make" without argument is like "make help".
diff --git a/docs/api.rst b/docs/api.rst
deleted file mode 100644
index 349f80f..0000000
--- a/docs/api.rst
+++ /dev/null
@@ -1,17 +0,0 @@
-.. _api_ref:
-
-.. automodule:: growbikenet
- :members:
- :undoc-members:
-
-.. currentmodule:: growbikenet
-
-growbikenet API reference
-==========================
-
-
-.. autosummary::
- :toctree: api/
-
- growbikenet
- functions
\ No newline at end of file
diff --git a/docs/api/growbikenet.functions.rst b/docs/api/growbikenet.functions.rst
deleted file mode 100644
index 90c82a2..0000000
--- a/docs/api/growbikenet.functions.rst
+++ /dev/null
@@ -1,10 +0,0 @@
-growbikenet.functions
-=====================
-
-.. automodule:: growbikenet.functions
-
-
- .. rubric:: Functions
-
- .. autosummary::
-
\ No newline at end of file
diff --git a/docs/api/growbikenet.growbikenet.rst b/docs/api/growbikenet.growbikenet.rst
deleted file mode 100644
index cf4771a..0000000
--- a/docs/api/growbikenet.growbikenet.rst
+++ /dev/null
@@ -1,9 +0,0 @@
-growbikenet.growbikenet
-=======================
-
-.. automodule:: growbikenet.growbikenet
-
-
- .. rubric:: Main
-
- .. autosummary::
\ No newline at end of file
diff --git a/docs/make.bat b/docs/make.bat
index 32bb245..83cf06c 100644
--- a/docs/make.bat
+++ b/docs/make.bat
@@ -7,7 +7,7 @@ REM Command file for Sphinx documentation
if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
-set SOURCEDIR=.
+set SOURCEDIR=source
set BUILDDIR=_build
%SPHINXBUILD% >NUL 2>NUL
diff --git a/docs/_static/logo_eu.png b/docs/source/_static/logo_eu.png
similarity index 100%
rename from docs/_static/logo_eu.png
rename to docs/source/_static/logo_eu.png
diff --git a/docs/_static/logo_innovationfund.png b/docs/source/_static/logo_innovationfund.png
similarity index 100%
rename from docs/_static/logo_innovationfund.png
rename to docs/source/_static/logo_innovationfund.png
diff --git a/docs/_static/logo_juststreets.png b/docs/source/_static/logo_juststreets.png
similarity index 100%
rename from docs/_static/logo_juststreets.png
rename to docs/source/_static/logo_juststreets.png
diff --git a/docs/_static/references.bib b/docs/source/_static/references.bib
similarity index 100%
rename from docs/_static/references.bib
rename to docs/source/_static/references.bib
diff --git a/docs/conf.py b/docs/source/conf.py
similarity index 55%
rename from docs/conf.py
rename to docs/source/conf.py
index 92e7908..5622d9c 100644
--- a/docs/conf.py
+++ b/docs/source/conf.py
@@ -15,13 +15,16 @@
import os # noqa
import sys # noqa
+from pathlib import Path # noqa
+from tomllib import load as toml_load # noqa
sys.path.insert(0, os.path.abspath(".."))
import growbikenet # noqa
-# version = growbikenet.__version__
-version = "0.8.0"
-release = version
+# dynamically load version
+with Path("../../pyproject.toml").open("rb") as f:
+ pyproject = toml_load(f)
+version = release = pyproject["project"]["version"]
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
@@ -55,25 +58,54 @@
html_static_path = ["_static"]
### select html theme
-# html_theme = 'alabaster'
html_theme = "furo"
html_theme_options = {
- "github_url": "https://github.com/BikeNetKit/GrowBikeNet",
- "twitter_url": "notwitter.com",
"pygment_light_style": "tango",
"logo": {
"image_light": "logo.png",
"image_dark": "logo.png",
},
+ "light_css_variables": {
+ "color-brand-primary": "#096a51",
+ "color-brand-content": "#096a51",
+ "color-brand-visited": "#5b8b75",
+ },
+ "dark_css_variables": {
+ "color-brand-primary": "#3cd71d",
+ "color-brand-content": "#3cd71d",
+ "color-brand-visited": "#5b8b75",
+ },
+ "footer_icons": [
+ {
+ "name": "Bluesky",
+ "url": "https://bsky.app/profile/bikenetkit.bsky.social",
+ "html": """
+
+ """,
+ "class": "",
+ },
+ {
+ "name": "GitHub",
+ "url": "https://github.com/BikeNetKit/GrowBikeNet",
+ "html": """
+
+ """,
+ "class": "",
+ },
+ ],
}
# Generate the API documentation when building
autosummary_generate = True
autosummary_imported_members = True
-numpydoc_show_class_members = True
-class_members_toctree = True
-numpydoc_show_inherited_class_members = True
+numpydoc_show_class_members = False
+class_members_toctree = False
+numpydoc_show_inherited_class_members = False
numpydoc_class_members_toctree = False
numpydoc_use_plots = True
autodoc_typehints = "none"
@@ -90,9 +122,8 @@
.. note::
| This page was generated from `{{ docname }}`__.
- | Interactive online version: :raw-html:``
- __ https://github.com/BikeNetKit/GrowBikeNet/blob/master/docs/{{ docname }}
+ __ https://github.com/BikeNetKit/GrowBikeNet/blob/main/docs/source/{{ docname }}
""" # noqa: E501
diff --git a/docs/usage/quickstart.rst b/docs/source/getting_started.rst
similarity index 59%
rename from docs/usage/quickstart.rst
rename to docs/source/getting_started.rst
index 4eab725..ed0d6c9 100644
--- a/docs/usage/quickstart.rst
+++ b/docs/source/getting_started.rst
@@ -1,8 +1,25 @@
-==========
-Quickstart
-==========
+Getting started
+===============
-GrowBikeNet takes one mandatory parameter, the city name, which it passes via `OSMnx `__ to `Nominatim `__, to download a city's street network. GrowBikeNet then runs the following operations:
+Get Started in 4 Steps
+----------------------
+
+1. Install GrowBikeNet by following the :doc:`installation` guide.
+
+2. Read the :ref:`introducing-growbikenet` section below.
+
+3. Run the :doc:`mwe`.
+
+4. Consult the :doc:`reference_user` for complete details on using the package.
+
+Finally, if you're not already familiar with `NetworkX`_ and `GeoPandas`_, make sure you read their user guides as GrowBikeNet uses their data structures.
+
+.. _introducing-growbikenet:
+
+Introducing GrowBikeNet
+-----------------------
+
+GrowBikeNet is built on top of `OSMnx`_/`NetworkX`_ and `GeoPandas`_. It takes one mandatory parameter, the city name, which it passes via `Nominatim`_ to `OSMnx`_, to download a city's street network. GrowBikeNet then runs the following operations:
* Optional, also download the city's existing bicycle network.
* Create seed points following :cite:t:`szell2022gub`. By default this is a grid, but it can also be set to the city's rail stations. If the city's existing bicycle network is used, the seed points are first selected on the bicycle network following :cite:t:`folco2023dmn`.
@@ -16,9 +33,15 @@ GrowBikeNet takes one mandatory parameter, the city name, which it passes via `O
* Optional, a video is generated in the results folder, using the plots as frames.
-Quickstart contents
--------------------
+To try it out, run the:
+
.. toctree::
:maxdepth: 1
- Minimum working example
\ No newline at end of file
+ Minimum working example
+
+
+.. _GeoPandas: https://geopandas.org
+.. _NetworkX: https://networkx.org
+.. _OSMnx: https://osmnx.readthedocs.io
+.. _Nominatim: https://nominatim.openstreetmap.org
\ No newline at end of file
diff --git a/docs/index.rst b/docs/source/index.rst
similarity index 69%
rename from docs/index.rst
rename to docs/source/index.rst
index f129e63..b51d08c 100644
--- a/docs/index.rst
+++ b/docs/source/index.rst
@@ -3,11 +3,10 @@
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
-===================================
GrowBikeNet |version| documentation
===================================
-The Python package `growbikenet` grows an urban bicycle network from scratch or from an existing bicycle network. It is part of `BikeNetKit `__.
+The Python package ``growbikenet`` grows an urban bicycle network from scratch or from an existing bicycle network. It is hosted on `Github `__, part of `BikeNetKit `__.
The software downloads and pre-processes data from OpenStreetMap,
prepares seed points to connect, runs simulations, saves the results,
@@ -19,14 +18,11 @@ paper `__ page.
-To use GrowBikeNet, the `Quickstart `__ page
-is a good place to start.
-More on the details of the inner workings can be found on
-the `Reference pages `__.
-Furthermore, you can also find the `API documentation `__.
+To set up GrowBikeNet, see the :doc:`installation` page.
+To use GrowBikeNet, the :doc:`getting_started` page
+is a good place to start, which also explains how the package works in detail. For technical documentation, consult the :doc:`reference_user`.
.. Statement of need
.. =================
@@ -34,19 +30,21 @@ Furthermore, you can also find the `API documentation `__.
.. TBA
How to cite
-===========
-If you use `growbikenet` in your research, please cite the paper `doi:10.1038/s41598-022-10783-y `__:
+-----------
+
+If you use GrowBikeNet in your research, please cite `the paper `__:
M. Szell, S. Mimar, T. Perlman, G. Ghoshal, R. Sinatra. Growing urban bicycle networks. Scientific Reports 12, 6765 (2022). https://doi.org/10.1038/s41598-022-10783-y
Contributing
-============
+------------
+
If you want to contribute to the development of GrowBikeNet, please read the
`CONTRIBUTING.md `__
file.
Supported by
-============
+------------
Development of BikeNetKit/GrowBikeNet was supported by the Innovation Fund Denmark
and the EU HORIZON grant JUST STREETS.
@@ -62,12 +60,14 @@ and the EU HORIZON grant JUST STREETS.
Documentation contents
-======================
+----------------------
+
.. toctree::
:maxdepth: 1
Home
- usage/installation
- usage/quickstart
- API reference
+ installation
+ getting_started
+ reference_user
+ reference_developer
references
diff --git a/docs/usage/installation.rst b/docs/source/installation.rst
similarity index 97%
rename from docs/usage/installation.rst
rename to docs/source/installation.rst
index 300d6ae..d252fd3 100644
--- a/docs/usage/installation.rst
+++ b/docs/source/installation.rst
@@ -137,7 +137,7 @@ gbnenv)
Development installation
-------------------------
+~~~~~~~~~~~~~~~~~~~~~~~~
If you want to develop the project, `clone this
repository `__
@@ -148,6 +148,6 @@ and create the environment via the
pixi init --import environment-dev.yml
-The developemt environment is called ``gbnenvdev``. Make sure to also
+The development environment is called ``gbnenvdev``. Make sure to also
read `our contribution
guidelines `__.
diff --git a/docs/source/mwe.ipynb b/docs/source/mwe.ipynb
new file mode 100644
index 0000000..2a5c096
--- /dev/null
+++ b/docs/source/mwe.ipynb
@@ -0,0 +1,124 @@
+{
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "id": "0",
+ "metadata": {},
+ "source": [
+ "# Minimum working example\n",
+ "This notebook runs a minimum working example with growbikenet."
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "1",
+ "metadata": {},
+ "source": [
+ "## Import growbikenet"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "66e59357-7987-4e0c-b5fa-8a261d3fedec",
+ "metadata": {},
+ "source": [
+ "The standard way of importing growbikenet:"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "2",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "import growbikenet as gbn"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "3",
+ "metadata": {},
+ "source": [
+ "## Run growbikenet on example city"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "4",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "edges_ranked = gbn.growbikenet(\"Lyon\")"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "4a20e33e-3bfa-4578-b21e-83e0a0b5993b",
+ "metadata": {},
+ "source": [
+ "## Explore results"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "039083d0-91f3-42cc-a377-9e555b25d6ca",
+ "metadata": {},
+ "source": [
+ "See the contents of the resulting geodataframe:"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "ec409ae0-4974-4ccb-984c-06c680a2c1a1",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "edges_ranked.head()"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "bcd2409f-bac6-4e7c-89e9-d8c229eb36d2",
+ "metadata": {},
+ "source": [
+ "Explore the results interactively:"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "fac59916-d789-4e4d-8415-81dd962e8fbb",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "edges_ranked.explore(tiles=\"CartoDB Positron\", # background map\n",
+ " style_kwds={\"weight\": 4, \"color\": \"#096a51\"}, # thick green lines\n",
+ " )"
+ ]
+ }
+ ],
+ "metadata": {
+ "kernelspec": {
+ "display_name": "Python 3 (ipykernel)",
+ "language": "python",
+ "name": "python3"
+ },
+ "language_info": {
+ "codemirror_mode": {
+ "name": "ipython",
+ "version": 3
+ },
+ "file_extension": ".py",
+ "mimetype": "text/x-python",
+ "name": "python",
+ "nbconvert_exporter": "python",
+ "pygments_lexer": "ipython3",
+ "version": "3.12.13"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 5
+}
diff --git a/docs/source/reference_developer.rst b/docs/source/reference_developer.rst
new file mode 100644
index 0000000..71aaf49
--- /dev/null
+++ b/docs/source/reference_developer.rst
@@ -0,0 +1,19 @@
+Developer reference
+===================
+
+This is the complete developer reference for the GrowBikeNet package. If you are looking for an introduction to GrowBikeNet, read the :doc:`getting_started` guide.
+
+growbikenet.growbikenet
+-----------------------
+
+.. automodule:: growbikenet.growbikenet
+ :members:
+
+growbikenet.functions
+---------------------
+
+.. automodule:: growbikenet.functions
+ :members:
+ :private-members:
+
+
\ No newline at end of file
diff --git a/docs/source/reference_user.rst b/docs/source/reference_user.rst
new file mode 100644
index 0000000..27bbeb6
--- /dev/null
+++ b/docs/source/reference_user.rst
@@ -0,0 +1,9 @@
+User reference
+==============
+
+This is the user reference for the GrowBikeNet package. If you are looking for an introduction to GrowBikeNet, read the :doc:`getting_started` guide.
+
+The standard way to import the GrowBikeNet package is via ``import growbikenet as gbn``. The main ``growbikenet()`` function below is then called via ``gbn.growbikenet()``, see the :doc:`mwe`.
+
+.. automodule:: growbikenet.growbikenet
+ :members:
\ No newline at end of file
diff --git a/docs/references.rst b/docs/source/references.rst
similarity index 100%
rename from docs/references.rst
rename to docs/source/references.rst
diff --git a/docs/usage/mwe.ipynb b/docs/usage/mwe.ipynb
deleted file mode 100644
index 0ddcb13..0000000
--- a/docs/usage/mwe.ipynb
+++ /dev/null
@@ -1,85 +0,0 @@
-{
- "cells": [
- {
- "cell_type": "markdown",
- "id": "0",
- "metadata": {},
- "source": [
- "## Minimum working example\n",
- "This notebook runs a minimum working example with growbikenet"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "1",
- "metadata": {},
- "source": [
- "### Import growbikenet"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "2",
- "metadata": {},
- "outputs": [],
- "source": [
- "import growbikenet as gbn"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "3",
- "metadata": {},
- "source": [
- "### Run growbikenet with example city Bath and rank by betweenness centrality"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "4",
- "metadata": {},
- "outputs": [],
- "source": [
- "a_edges = gbn.growbikenet(\n",
- " city_name=\"Bath\",\n",
- " proj_crs=\"3857\",\n",
- " ranking=\"betweenness_centrality\",\n",
- " export_data=True,\n",
- " export_plots=False,\n",
- " export_video=False,\n",
- ")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "5",
- "metadata": {},
- "source": [
- "data is saved in .examples/"
- ]
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Python 3 (ipykernel)",
- "language": "python",
- "name": "python3"
- },
- "language_info": {
- "codemirror_mode": {
- "name": "ipython",
- "version": 3
- },
- "file_extension": ".py",
- "mimetype": "text/x-python",
- "name": "python",
- "nbconvert_exporter": "python",
- "pygments_lexer": "ipython3",
- "version": "3.12.13"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 5
-}
diff --git a/examples/mwe.ipynb b/examples/mwe.ipynb
index 0ddcb13..2a5c096 100644
--- a/examples/mwe.ipynb
+++ b/examples/mwe.ipynb
@@ -5,8 +5,8 @@
"id": "0",
"metadata": {},
"source": [
- "## Minimum working example\n",
- "This notebook runs a minimum working example with growbikenet"
+ "# Minimum working example\n",
+ "This notebook runs a minimum working example with growbikenet."
]
},
{
@@ -14,7 +14,15 @@
"id": "1",
"metadata": {},
"source": [
- "### Import growbikenet"
+ "## Import growbikenet"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "66e59357-7987-4e0c-b5fa-8a261d3fedec",
+ "metadata": {},
+ "source": [
+ "The standard way of importing growbikenet:"
]
},
{
@@ -32,7 +40,7 @@
"id": "3",
"metadata": {},
"source": [
- "### Run growbikenet with example city Bath and rank by betweenness centrality"
+ "## Run growbikenet on example city"
]
},
{
@@ -42,22 +50,53 @@
"metadata": {},
"outputs": [],
"source": [
- "a_edges = gbn.growbikenet(\n",
- " city_name=\"Bath\",\n",
- " proj_crs=\"3857\",\n",
- " ranking=\"betweenness_centrality\",\n",
- " export_data=True,\n",
- " export_plots=False,\n",
- " export_video=False,\n",
- ")"
+ "edges_ranked = gbn.growbikenet(\"Lyon\")"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "4a20e33e-3bfa-4578-b21e-83e0a0b5993b",
+ "metadata": {},
+ "source": [
+ "## Explore results"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "039083d0-91f3-42cc-a377-9e555b25d6ca",
+ "metadata": {},
+ "source": [
+ "See the contents of the resulting geodataframe:"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "ec409ae0-4974-4ccb-984c-06c680a2c1a1",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "edges_ranked.head()"
]
},
{
"cell_type": "markdown",
- "id": "5",
+ "id": "bcd2409f-bac6-4e7c-89e9-d8c229eb36d2",
"metadata": {},
"source": [
- "data is saved in .examples/"
+ "Explore the results interactively:"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "fac59916-d789-4e4d-8415-81dd962e8fbb",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "edges_ranked.explore(tiles=\"CartoDB Positron\", # background map\n",
+ " style_kwds={\"weight\": 4, \"color\": \"#096a51\"}, # thick green lines\n",
+ " )"
]
}
],
diff --git a/examples/mwe.py b/examples/mwe.py
index 5edb738..d68184e 100644
--- a/examples/mwe.py
+++ b/examples/mwe.py
@@ -2,15 +2,4 @@
import growbikenet as gbn
-a_edges = gbn.growbikenet(
- city_name="Oelde",
- ranking="betweenness_centrality",
- existing_network_spacing=None,
- export_file_format="gpkg",
- export_data=True,
- export_plots=False,
- export_video=False,
- allow_edge_overlaps=False,
-)
-
-# data is saved in current working directory
+edges_ranked = gbn.growbikenet("Lyon")
diff --git a/growbikenet/functions.py b/growbikenet/functions.py
index 21f7c11..b3a1135 100644
--- a/growbikenet/functions.py
+++ b/growbikenet/functions.py
@@ -1,5 +1,4 @@
-"""Utility functions for growbikenet
-"""
+"""Utility functions for growbikenet."""
import numpy as np
import pandas as pd
@@ -695,16 +694,16 @@ def rank_df(df, method):
Dataframe sorted by specified ranking method.
"""
if method == "random": # ranking is random
- df["ordering_random"] = np.random.permutation(np.arange(df.shape[0]))
- df = df.sort_values(by="ordering_random", ascending=False)
+ df["rank"] = np.random.permutation(np.arange(df.shape[0]))
+ df = df.sort_values(by="rank", ascending=False)
df.reset_index(drop=True, inplace=True)
- df["ordering_" + method] = (
+ df["rank"] = (
df.index
)
else: # ranking is the order of appearance in the method's ranking
df = df.sort_values(by=method, ascending=False)
df.reset_index(drop=True, inplace=True)
- df["ordering_" + method] = (
+ df["rank"] = (
df.index
)
return df
diff --git a/growbikenet/growbikenet.py b/growbikenet/growbikenet.py
index de41aed..920d4c7 100644
--- a/growbikenet/growbikenet.py
+++ b/growbikenet/growbikenet.py
@@ -44,39 +44,39 @@ def growbikenet(
allow_edge_overlaps=False,
city_boundary_file=None,
):
- """Creates a list of edges ordered by a specified ranking method.
+ """Creates a list of urban street network edges ordered by a ranking method.
- The edges form a subnetwork of a city's street network, interpreted as a growing bicycle network following [1]_. By default, growth is from scratch, but the existing bicycle network can also be used as a starting point[2]_. Note that the original paper [1]_ uses minimum weight triangulation, but Delaunay triangulation is much faster due to the Delaunay scipy function and gives in most cases identical results. Triangulation and metrics (betweenness, closeness) are calculated for the abstract network for which egde lengths are taken from the routed network.
+ The edges form a subnetwork of a city's street network, interpreted as a growing bicycle network following [1]_. By default, growth is from scratch, but the existing bicycle network can also be used as a starting point[2]_. The original paper [1]_ uses minimum weight triangulation, but Delaunay triangulation is implemented much faster and in practice gives identical results. Triangulation and metrics (betweenness, closeness) are calculated for the abstract network for which egde lengths are taken from the routed network.
Parameters
----------
city_name : str
Name of the city that the analysis should be performed on. This is the query string used to fetch the data from nominatim. Overruled (for data fetching) if city_boundary_file is set.
- proj_crs : str, default '3857'
+ proj_crs : str, optional, default '3857'
Coordinate reference system that is used to project osm data. Default is '3857' (WGS 84 / Pseudo-Mercator). If this web mercator projection is not needed, then for Europe '3035' (LAEA) and globally '54035' (Equal Earth) is better.
- ranking : str, default 'betweenness_centrality'
+ ranking : str, optional, default 'betweenness_centrality'
Method used to rank edges. Must be 'betweenness_centrality' (default), 'closeness_centrality', or 'random'.
seed_point_type : str, optional, default 'grid'
- If set to 'grid', creates a square grid
- If set to 'rail', uses rail stations
+ If set to 'grid', creates a square grid.
+ If set to 'rail', uses rail stations.
seed_point_grid_spacing : int, optional, default 1707
- If seed_point_type is set to 'grid', this is the spacing between seed points, in meters
+ If seed_point_type is set to 'grid', this is the spacing between seed points, in meters.
seed_point_delta : int, optional, default 500
- Maximum distance between generated seed points and osm nodes for snapping
+ Maximum distance between generated seed points and osm nodes for snapping, in meters.
existing_network_spacing : int, optional, default None
Spacing between seed points, in meters, only on the existing bicycle network. If not set to a positive integer, the existing network is ignored.
export_data : bool, optional, default True
- If set to True, data will be saved to a file. The filename is [slug]-[ranking]-[seed_point_type].gpkg, where slug is a string id made out of city_name.
+ If set to True, data is saved to a file. The filename is [slug]-[ranking]-[seed_point_type].[export_file_format], where slug is a string id made out of city_name.
export_data_slug : str, optional, default None
- If not set to None, the city_name will be slugified and used as the slug in the filename of the data export
+ If not set to None, the city_name will be slugified and used as the slug in the filename of the data export.
export_file_format : str, optional, default "geojson"
File format for the data export, relevant if export_data set to True. Default "geojson", also possible "gpkg". If exporting as geojson, generates extra files for seed points and city boundary. If exporting as gkpg, these are added all in one file as extra layers.
export_plots : bool, optional, default False
- If set to True, plots will be saved to files. Will overwrite previous files.
+ If set to True, plots are saved to files, overwriting existing ones.
export_video : bool, optional, default False
- If set to True, video will be saved to a file (only possible if export_plots is set to True). Will overwrite previous files.
+ If set to True, video is saved to file (only possible if export_plots is set to True), overwriting existing ones.
allow_edge_overlaps : bool, default False
- If set to False, removes edge overlaps in consecutive growth stages. In this case, growth stages that do not add anything new are deleted.
+ If set to False, removes edge overlaps in consecutive growth stages and deketed growth stages that do not add anything new.
city_boundary_file : (str | None), default None
If not set to None, the study area will be selected from the (Multi)Polygon provided in the city_boundary_file shape file, ideally in unprojected latitude-longitude degrees (EPSG:4326), but EPSG:3857 also works. For example, "./tests/test_data/copenhagen.shp".
@@ -333,7 +333,7 @@ def growbikenet(
if export_data:
### save data
pbar = tqdm(
- desc="{:<23}".format("Saving data"),
+ desc="{:<23}".format("Exporting data"),
total=1,
unit="step",
bar_format='{l_bar}{bar:16}{r_bar}',
@@ -389,9 +389,17 @@ def growbikenet(
os.makedirs("./results/plots/ordering_"+ranking+"/video/", exist_ok=True)
make_video(img_folder_name="./results/plots/ordering_"+ranking+"/", fps=5)
- endtime = time.time()
-
print("----------------------------------------------╯")
+ if export_data:
+ print("Data exported to results/")
+ if export_plots:
+ print("Plots exported to results/plots/")
+ if export_video:
+ print("Video exported to results/plots/")
+ if export_data or export_plots or export_video:
+ print("-----------------------------------------------")
+
+ endtime = time.time()
print("FINISHED IN " + str(datetime.timedelta(seconds = round(endtime - starttime))))
print("==============================================")
diff --git a/tests/test_functions.py b/tests/test_functions.py
index d5c9331..b5bc8e2 100644
--- a/tests/test_functions.py
+++ b/tests/test_functions.py
@@ -39,7 +39,7 @@ def test_data_rank(method):
@pytest.fixture
def validation_data_rank(method):
ranked_df = pd.DataFrame(
- ([6, 0], [4, 1], [2, 2]), columns=[method, "ordering_betweenness_centrality"]
+ ([6, 0], [4, 1], [2, 2]), columns=[method, "rank"]
)
return ranked_df