In this exploratory data analysis, we examined the data.nantesmetropole.fr database containing information on cycling facilities in the city of Nantes. We used Python and Plotly libraries to visualize and present the results.
In 2020/2021, a new comprehensive inventory of cycling facilities in the territory of Nantes Métropole was carried out. This inventory induces changes in the cartographic representation of the objects bringing more precision on the cycling lines: the geometric representation is now performed on the individual axis of each cycling development (a cycle lane on each side of the roadway gives rise to two linear objects), an attribute on each object provides information on the specificity of a bi-directional cycle layout or not. The data come from a comprehensive inventory conducted in 2020 and 2021 on spaces open to public traffic (including dedicated bike lanes).
Data and Variables
After installing the necessary libraries, we import and load the data into a Pandas dataframe.
pip install pandas plotly
import pandas as pd #Gestion de données
import matplotlib.pyplot as plt #Visualisation de données
import geopandas as gpd #Gestion données spatiales
import plotly.express as px
cyclables_nantes = pd.read_csv('cyclables_nantes.csv', sep=';')
Explore and prepare the data
Before performing visualizations, it is important to explore and prepare the data as needed. We perform operations to filter, count, group and transform the data according to its type. It is also necessary to check for null data and select the columns or variables we are going to work with.
cyclables_nantes.info()
cyclables_nantes.dtypes
cyclables_nantes.isnull().sum()
All the code is available in a link to Github at the end of the publication.
From the database we filter the following variables:
- Municipality: the municipality to which the bikeway belongs.
- Latitude: The latitude coordinate of the bikeway.
- Longitude: The longitude coordinate of the bikeway.
- Geometry: Additional information about the geometry of the bikeway.
- Track type: The type of bikeway, such as bike lane, cycle path, etc.
- Length: The length of the bikeway in meters.
The classification of different cycling facilities comprises 8 objects:
– Cycle lanes: space reserved exclusively for cyclists on the roadway, separated from motorized traffic by a simple marking (and not by a separator referenced as characteristic of a cycle track). The space is generally delimited by a strip of paint. Bicycle lane markings can be identified in the field by a cyclist figure and/or chevrons.
– Unidirectional or bidirectional cycle paths: a roadway reserved exclusively for two- or three-wheeled cycles. They can be unidirectional or bidirectional. In the field, a cycle lane can be identified by the fact that it is located outside the part of the road used by all other users (especially cars) and is separated from this road by one of the following types of separator.
- Two-way cycling: Two-way cycling, or “D.S.C.”, is not so much an object as a concept or characteristic of a street. A “two-way” street is one with two-way – or bi-directional – traffic flow, but one of these directions is reserved for cyclists only. Double-sens cyclable”, or “D.S.C.”, is not so much an object as a concept or characteristic of a street. A “two-way cycle lane” is a two-way – or bi-directional – street, but one of these directions is reserved for cyclists only. Careful attention should be paid to the street’s name, and although the expression contre-sens cyclable (contra-sense cycle lane) may have been used regularly in the past, its use should be avoided to avoid confusion with contra-sense traffic, which is an offence.
– Greenways: lanes reserved exclusively for non-motorized vehicles, pedestrians and horse riders. It is characterized by the presence, at each end, of signs C115 at the entrance and C116 at the end of the greenway.
– Bus lanes: bus lanes can be equipped with a combination of bicycle figures and widely-spaced guide markings. Overpasses: on bridges, the right-of-way is often limited, forcing cyclists to share the same space.
Analysis questions
Based on this database, we asked ourselves the following questions and answered them using interactive visualizations:
- How many cycle paths are there in each municipality?
via_count_municipio = cyclables_nantes_ok.groupby('commune').size().reset_index(name='Cantidad')
fig = px.bar(via_count_municipio, x='commune', y='Cantidad',
title='Combien y a-t-il de voies cyclables dans chaque municipalité ?')
fig.update_layout(xaxis_title='Commune', yaxis_title='Nombre de pistes cyclables')
fig.show()
2. What is the distribution of the types of bicycle lanes?
via_count_tipo = cyclables_nantes_ok['type_amenagement'].value_counts().reset_index()
via_count_tipo.columns = ['type_amenagement', 'Cantidad']
fig = px.pie(via_count_tipo, names='type_amenagement', values='Cantidad',
title='Répartition des types de voies cyclables ?')
fig.show()
3. What is the total length of bicycle lanes per municipality?
via_length_municipio = cyclables_nantes_ok.groupby('commune')['shape_length'].sum().reset_index(name='Longitud total')
fig = px.bar(via_length_municipio, x='commune', y='Longitud total',
title='Longueur totale des voies cyclables par municipalité ?')
fig.update_layout(xaxis_title='Commune', yaxis_title='Longueur totale')
fig.show()
4. What is the average length of bikeways by type of road?
via_avg_length_tipo = cyclables_nantes_ok.groupby('type_amenagement')['shape_length'].mean().reset_index(name='Longitud promedio')
fig = px.bar(via_avg_length_tipo, x='type_amenagement', y='Longitud promedio',
title='Longueur moyenne des voies cyclables par type de voie ')
fig.update_layout(xaxis_title='Type Aménagement', yaxis_title='Longueur moyenne')
fig.show()
5. What are the longest cycle paths?
top_longest_vias = cyclables_nantes_ok.nlargest(10, 'shape_length')
fig = px.bar(top_longest_vias, x='shape_length', y='type_amenagement', orientation='h',
title='Voies cyclables les plus longues par commune', color='commune')
fig.update_layout(xaxis_title='Longueur', yaxis_title='Type amenagement')
fig.show()
6. What is the cumulative length of bikeways by type of road?
via_cumulative_length = cyclables_nantes_ok.groupby('type_amenagement')['shape_length'].sum().cumsum().reset_index(name='Longitud acumulada')
fig = px.area(via_cumulative_length, x='type_amenagement', y='Longitud acumulada',
title='Longueur cumulée des voies cyclables par type de voie ')
fig.update_layout(xaxis_title='Type amenagement', yaxis_title='Longueur cumulée')
fig.show()
7. What is the distribution of bikeway lengths?
fig = go.Figure(data=[go.Histogram(x=cyclables_nantes_ok[‘shape_length’])])
fig.update_layout(title=’Distribution des longueurs des voies cyclables’,
xaxis_title=’Longueur’, yaxis_title=’Fréquence’)
fig.show()
8. What is the cumulative length of bikeways per municipality?
via_cumulative_length_municipio = cyclables_nantes_ok.groupby('commune')['shape_length'].sum().cumsum().reset_index(name='Longitud acumulada')
fig = px.line(via_cumulative_length_municipio, x='commune', y='Longitud acumulada',
title='Longueur cumulée des voies cyclables par commune')
fig.update_layout(xaxis_title='Commune', yaxis_title='Longueur cumulée')
fig.show()
9. What are the most common cycle paths by municipality?
top_common_vias_municipio = cyclables_nantes_ok.groupby(['commune', 'type_amenagement']).size().reset_index(name='Cantidad')
top_common_vias_municipio = top_common_vias_municipio.sort_values(['commune', 'Cantidad'], ascending=[True, False])
top_common_vias_municipio = top_common_vias_municipio.groupby('commune').head(1)
fig = px.bar(top_common_vias_municipio, x='commune', y='Cantidad', color='type_amenagement',
title='Voies cyclables les plus courantes par commune')
fig.update_layout(xaxis_title='Commune', yaxis_title='Nombre', legend_title='Type amenagement')
fig.show()
10. What is the geographical distribution of cycle paths in Nantes?
fig = px.scatter_mapbox(cyclables_nantes_ok, lat='Latitude', lon='Longitude', hover_name='type_amenagement', hover_data=['shape_length'],
color='type_amenagement', zoom=10, height=600)
fig.update_layout(mapbox_style='open-street-map')
fig.update_layout(title='Répartition géographique des voies cyclables à Nantes')
fig.show()
Conclusions
Through the analysis of the data on cycle paths in Nantes, we have obtained valuable information on the number, length, distribution and types of cycle paths in each municipality. Some notable findings are:
- Nantes has the highest number of cycle paths with 4295, followed by Saint-Herblain with 727.
- The most common cycle paths are cycle lanes, followed by cycle paths.
- The total length of cycle paths varies significantly between municipalities, where Nantes stands out as the capital city with 273190 m, having the longest total length.
- When calculating the longest cycle paths per municipality, we find that Bouguenais is the first with 2808 mts in pedestrian-bicycle cohabitation.
- There is an uneven distribution of cycleway lengths, with most of them concentrated in the 0-5 km range.
- The cumulative length of bicycle lanes shows a steady growth in most lane types.
These findings provide us with important information to understand how the cycling infrastructure in Nantes is constituted and can be used to improve the planning and development of the cycleway network in the city.
In summary, this exploratory data analysis has allowed us to better visualize and understand the characteristics and distribution of cycle paths in Nantes. Interactive visualizations created with Python and the Plotly libraries have helped us to effectively analyze and present the information in a clear and concise manner.
Sources
Aménagements cyclables de Nantes Métropole