Week2 Lab Tutorial Timeline
Time |
Activity |
|---|---|
16:00–16:05 |
Introduction — Overview of the main tasks for the lab tutorials |
16:05–16:45 |
Tutorial: geometric operation — Follow Section 2.1 of the Jupyter Notebook to practice the overlay, dissolve and buffer analysis |
16:45–17:30 |
Tutorial: spatial join — Follow Section 2.2 of the Jupyter Notebook to practice the spatial join |
17:30–17:55 |
Quiz — Complete quiz tasks |
17:55–18:00 |
Wrap-up — Recap key points and address final questions |
For this module’s lab tutorials, you can download all the required data using the provided link (click).
Please make sure that both the Jupyter Notebook file and the data and img folder are placed in the same directory (specifically within the STBDA_lab folder) to ensure the code runs correctly.
Week 2 Key Takeaways:
Perform geometric operations on geospatial data including overlay, dissolve, and buffer analysis;
Apply geometric operations to analyze relationships between geographic objects;
Combine different geospatial datasets using spatial joins;
Create buffers and zones around geographic objects and implement buffer analysis;
Perform spatial analysis to extract meaningful insights from real urban complex data.
2 Geospatial data operations and processing#
2.1 Geometric manipulation/operations#
2.1.1 Overlay#
In this section, we will learn how to perform overlay operations on geospatial data. Overlay operations are used to combine two or more layers of geospatial data to create a new layer that contains information from all the input layers. There are four main types of overlay operations: intersection, union, difference, and symmetric difference in Geopandas overlay function.
(Spatial overlay with two input vector layers (a_input = rectangle, b_input = circle). The resulting vector layer is displayed in green. QGIS documentation)
Here, we use the London Local authorities selected from UK local authority boundaries used in the previous week and the London Inner Ultra Low Emission Zone (ULEZ) boundary 2019 or called central London Congestion Charge Zone (CCZ) now. The London congestion charge zone is a designated area in central London where drivers are required to pay a fee to drive within the zone during certain hours. The ULEZ is an area in London where only vehicles that meet strict emissions standards can enter without paying a charge. (Please note the boundary of ULEZ 2019/CCZ was expanded in 2021 and 2023, but we use the CCZ boundary in this case).
# load the required libraries
import geopandas as gpd
import warnings
from matplotlib import pyplot as plt
warnings.filterwarnings('ignore')
# Read the UK Local Authority boundaries in geojson
gdf_uk_la = gpd.read_file("data/Local_Authority_Districts_December_2024_Boundaries_UK_BSC.geojson")
# Selecting London Local Authority boundaries by using the index in the LAD24CD column.
# As all London LA index code starts with 'E09', we can use the string method to filter the data.
gdf_uk_london = gdf_uk_la[gdf_uk_la['LAD24CD'].str.startswith('E09')]
# We can observe that London has 33 local authorities (33 rows in GeoDataFrame).
gdf_uk_london
| FID | LAD24CD | LAD24NM | LAD24NMW | BNG_E | BNG_N | LONG | LAT | GlobalID | geometry | |
|---|---|---|---|---|---|---|---|---|---|---|
| 263 | 264 | E09000001 | City of London | 532382 | 181358 | -0.093520 | 51.51564 | 741710fd-03e1-4b41-8645-7ebcfc5961ac | POLYGON ((-0.07853 51.52151, -0.07687 51.51663... | |
| 264 | 265 | E09000002 | Barking and Dagenham | 547757 | 185111 | 0.129479 | 51.54556 | a2f59957-115c-478b-8c27-5162ee915dc7 | POLYGON ((0.15436 51.56611, 0.16189 51.56162, ... | |
| 265 | 266 | E09000003 | Barnet | 523473 | 191752 | -0.218200 | 51.61107 | 9c7bda3b-2831-4799-857a-c83a49d16e4e | POLYGON ((-0.19987 51.67017, -0.19107 51.6639,... | |
| 266 | 267 | E09000004 | Bexley | 549202 | 175434 | 0.146212 | 51.45823 | ce2684df-0b6a-45fb-a5f7-85b9ab35e0de | POLYGON ((0.18654 51.48046, 0.20084 51.47866, ... | |
| 267 | 268 | E09000005 | Brent | 519615 | 186465 | -0.275690 | 51.56439 | 3b5f8a90-cb62-4570-984f-fbf322e910bc | POLYGON ((-0.2495 51.58557, -0.25173 51.58338,... | |
| 268 | 269 | E09000006 | Bromley | 542036 | 165707 | 0.039246 | 51.37266 | 13f562be-b8cb-427c-bf86-0f845358e1ac | POLYGON ((0.03975 51.44098, 0.05821 51.42487, ... | |
| 269 | 270 | E09000007 | Camden | 527491 | 184283 | -0.162910 | 51.54305 | 88f3f650-53ac-434d-883e-6235b48d14c4 | POLYGON ((-0.13842 51.55687, -0.13072 51.55067... | |
| 270 | 271 | E09000008 | Croydon | 533922 | 164745 | -0.077620 | 51.36599 | c8fce222-bb0d-4a51-a695-68c991b41d31 | POLYGON ((-0.11263 51.42324, -0.10596 51.42259... | |
| 271 | 272 | E09000009 | Ealing | 517055 | 181959 | -0.314100 | 51.52443 | b2200ae0-425c-441f-88f8-b3ad3afc2152 | POLYGON ((-0.33556 51.55656, -0.31253 51.54903... | |
| 272 | 273 | E09000010 | Enfield | 532831 | 196198 | -0.081440 | 51.64890 | 53c0b28d-45c0-462e-96ff-dd23c7f8cead | POLYGON ((-0.08389 51.68991, -0.06209 51.68298... | |
| 273 | 274 | E09000011 | Greenwich | 542507 | 175878 | 0.050093 | 51.46394 | c559fa29-c300-4d10-8c1f-c0ea59815fa1 | MULTIPOLYGON (((-0.01733 51.4802, -0.01876 51.... | |
| 274 | 275 | E09000012 | Hackney | 534560 | 185787 | -0.060460 | 51.55493 | a41cf0fc-95ed-4823-a9db-7b8bc60f421b | POLYGON ((-0.01717 51.55158, -0.01655 51.54333... | |
| 275 | 276 | E09000013 | Hammersmith and Fulham | 523867 | 177993 | -0.217350 | 51.48733 | fb263bb7-9972-416c-9e8c-fc6966c08221 | POLYGON ((-0.21503 51.50219, -0.20795 51.49603... | |
| 276 | 277 | E09000014 | Haringey | 531260 | 189349 | -0.106700 | 51.58772 | a4407a53-4227-42ea-be81-5933bf73fc98 | POLYGON ((-0.11562 51.60842, -0.11445 51.6084,... | |
| 277 | 278 | E09000015 | Harrow | 515359 | 189736 | -0.335990 | 51.59467 | 72e2ba10-bf08-4504-8775-6fd08d725dd7 | POLYGON ((-0.2842 51.5905, -0.28246 51.58505, ... | |
| 278 | 279 | E09000016 | Havering | 555032 | 187514 | 0.235368 | 51.56520 | ef6d5be3-a2f9-4ad8-8c35-5cdc37e0bf9e | POLYGON ((0.22409 51.63174, 0.26326 51.60919, ... | |
| 279 | 280 | E09000017 | Hillingdon | 508168 | 183121 | -0.441790 | 51.53664 | ac5e6b28-6cc5-413b-b5b0-2d86048fe3f1 | POLYGON ((-0.45974 51.61316, -0.45713 51.61229... | |
| 280 | 281 | E09000018 | Hounslow | 512737 | 174959 | -0.378550 | 51.46239 | a53588f2-bf1c-41b5-83f7-d0e7419b35df | POLYGON ((-0.27418 51.49729, -0.26906 51.49403... | |
| 281 | 282 | E09000019 | Islington | 531160 | 184645 | -0.109900 | 51.54547 | 43a872fc-e401-45af-a2e6-3b2befc98837 | POLYGON ((-0.07768 51.54948, -0.07669 51.54609... | |
| 282 | 283 | E09000020 | Kensington and Chelsea | 525756 | 179054 | -0.189780 | 51.49645 | 29dc7a0f-a487-4156-a842-975bea2a337d | POLYGON ((-0.19991 51.51684, -0.19917 51.51454... | |
| 283 | 284 | E09000021 | Kingston upon Thames | 519508 | 167389 | -0.283680 | 51.39296 | 1e70f43d-4ddf-47dc-88bb-4df2efbfcafc | POLYGON ((-0.25424 51.4293, -0.24952 51.41478,... | |
| 284 | 285 | E09000022 | Lambeth | 531118 | 175629 | -0.113850 | 51.46445 | 9143bbc4-6bda-4e17-8148-cae2813f694d | POLYGON ((-0.09936 51.47264, -0.09598 51.46987... | |
| 285 | 286 | E09000023 | Lewisham | 537888 | 173343 | -0.017340 | 51.44230 | 99f48b46-bb26-47d7-8c90-bab1eeba4425 | POLYGON ((-0.01876 51.47891, -0.02274 51.47535... | |
| 286 | 287 | E09000024 | Merton | 526068 | 169508 | -0.188690 | 51.41059 | 2e85b11a-12d0-45c2-862c-ffd0dce83b1a | POLYGON ((-0.18985 51.44027, -0.18977 51.43135... | |
| 287 | 288 | E09000025 | Newham | 540713 | 183346 | 0.027261 | 51.53150 | 70e80979-1178-4228-9ae5-2e8d09e17e69 | POLYGON ((0.05034 51.56402, 0.06015 51.55641, ... | |
| 288 | 289 | E09000026 | Redbridge | 543512 | 189477 | 0.070085 | 51.58588 | 947652cf-8d04-498f-aeac-8cb34f1052d8 | POLYGON ((0.02182 51.62883, 0.04079 51.61573, ... | |
| 289 | 290 | E09000027 | Richmond upon Thames | 519005 | 172650 | -0.289140 | 51.44035 | 533a2a77-3779-4660-b9de-90d93540ee21 | POLYGON ((-0.23296 51.47168, -0.23357 51.46535... | |
| 290 | 291 | E09000028 | Southwark | 533945 | 175869 | -0.073090 | 51.46595 | 7d09d625-212a-4819-9b12-36c8d8d2b697 | POLYGON ((-0.07083 51.50252, -0.07351 51.50046... | |
| 291 | 292 | E09000029 | Sutton | 527357 | 163639 | -0.172270 | 51.35755 | 1b5d57bc-1cb5-43e1-85ba-3bb45da0b7cc | POLYGON ((-0.16995 51.39173, -0.1653 51.388, -... | |
| 292 | 293 | E09000030 | Tower Hamlets | 536340 | 181452 | -0.036480 | 51.51555 | 54f82e61-dc15-42cb-b777-681b4326f855 | POLYGON ((-0.03319 51.54469, -0.02899 51.54227... | |
| 293 | 294 | E09000031 | Waltham Forest | 537328 | 190278 | -0.018800 | 51.59462 | 97cd624f-2c02-4f12-a78e-7aedc777673f | POLYGON ((0.02009 51.62643, 0.01454 51.61889, ... | |
| 294 | 295 | E09000032 | Wandsworth | 525152 | 174138 | -0.200220 | 51.45240 | 9c51587a-4315-449d-bcc7-e65625e402f7 | POLYGON ((-0.14969 51.46129, -0.14814 51.4564,... | |
| 295 | 296 | E09000033 | Westminster | 528268 | 180871 | -0.152950 | 51.51222 | a52ff0f8-4ac0-4417-8338-01be3cbb516a | POLYGON ((-0.17348 51.53765, -0.1649 51.53578,... |
# We check the coordinate reference system (CRS) of the London local authority boundaries, which is WGS 84.
gdf_uk_london.crs
<Geographic 2D CRS: EPSG:4326>
Name: WGS 84
Axis Info [ellipsoidal]:
- Lat[north]: Geodetic latitude (degree)
- Lon[east]: Geodetic longitude (degree)
Area of Use:
- name: World.
- bounds: (-180.0, -90.0, 180.0, 90.0)
Datum: World Geodetic System 1984 ensemble
- Ellipsoid: WGS 84
- Prime Meridian: Greenwich
# We can plot the London local authority boundaries using the plot method.
gdf_uk_london.plot(figsize=(6, 6), edgecolor='grey', color='skyblue', alpha=0.7, linewidth=0.4)
<Axes: >
# We read the ULEZ 2019 / CCZ boundary in shp format.
gdf_ccz = gpd.read_file("data/ULEZ_2019_Central_Congestion_Charging_Zone/UltraLowEmissionsZoneBoundary(ULEZ).shp")
# We can observe that the CCZ boundary has 1 row (CCZ is a single polygon).
gdf_ccz
| OBJECTID | BOUNDARY | Shape_Area | geometry | |
|---|---|---|---|---|
| 0 | 1 | CSS Area | 21.375571 | POLYGON ((531562.664 183054.181, 531582.254 18... |
# Check the CRS of the CCZ boundary, which is OSGB 1936 / British National Grid.
gdf_ccz.crs
<Projected CRS: EPSG:27700>
Name: OSGB36 / British National Grid
Axis Info [cartesian]:
- E[east]: Easting (metre)
- N[north]: Northing (metre)
Area of Use:
- name: United Kingdom (UK) - offshore to boundary of UKCS within 49°45'N to 61°N and 9°W to 2°E; onshore Great Britain (England, Wales and Scotland). Isle of Man onshore.
- bounds: (-9.01, 49.75, 2.01, 61.01)
Coordinate Operation:
- name: British National Grid
- method: Transverse Mercator
Datum: Ordnance Survey of Great Britain 1936
- Ellipsoid: Airy 1830
- Prime Meridian: Greenwich
# Plot the CCZ boundary using the plot method.
gdf_ccz.plot(figsize=(6, 6), edgecolor='grey', color='red', alpha=0.3, linewidth=0.4)
<Axes: >
We need compatible CRS to perform overlay operations, which means that we should use map projection to change WGS 84 to OSGB 1936 / British National Grid. (We recommend using the projected CRS as the projected CRS is more accurate than the geographic CRS).
# Change London LA boundaries CRS from WGS 84 to OSGB 1936 / British National Grid.
gdf_uk_london = gdf_uk_london.to_crs(epsg=27700)
gdf_uk_london
| FID | LAD24CD | LAD24NM | LAD24NMW | BNG_E | BNG_N | LONG | LAT | GlobalID | geometry | |
|---|---|---|---|---|---|---|---|---|---|---|
| 263 | 264 | E09000001 | City of London | 532382 | 181358 | -0.093520 | 51.51564 | 741710fd-03e1-4b41-8645-7ebcfc5961ac | POLYGON ((533404.882 182037.774, 533534.125 18... | |
| 264 | 265 | E09000002 | Barking and Dagenham | 547757 | 185111 | 0.129479 | 51.54556 | a2f59957-115c-478b-8c27-5162ee915dc7 | POLYGON ((549415.046 187447.397, 549951.663 18... | |
| 265 | 266 | E09000003 | Barnet | 523473 | 191752 | -0.218200 | 51.61107 | 9c7bda3b-2831-4799-857a-c83a49d16e4e | POLYGON ((524579.909 198355.204, 525206.015 19... | |
| 266 | 267 | E09000004 | Bexley | 549202 | 175434 | 0.146212 | 51.45823 | ce2684df-0b6a-45fb-a5f7-85b9ab35e0de | POLYGON ((551929.394 177989.748, 552928.813 17... | |
| 267 | 268 | E09000005 | Brent | 519615 | 186465 | -0.275690 | 51.56439 | 3b5f8a90-cb62-4570-984f-fbf322e910bc | POLYGON ((521373.205 188863.227, 521224.977 18... | |
| 268 | 269 | E09000006 | Bromley | 542036 | 165707 | 0.039246 | 51.37266 | 13f562be-b8cb-427c-bf86-0f845358e1ac | POLYGON ((541860.07 173304.943, 543192.771 171... | |
| 269 | 270 | E09000007 | Camden | 527491 | 184283 | -0.162910 | 51.54305 | 88f3f650-53ac-434d-883e-6235b48d14c4 | POLYGON ((529150.075 185862.023, 529701.341 18... | |
| 270 | 271 | E09000008 | Croydon | 533922 | 164745 | -0.077620 | 51.36599 | c8fce222-bb0d-4a51-a695-68c991b41d31 | POLYGON ((531320.674 171048.561, 531786.297 17... | |
| 271 | 272 | E09000009 | Ealing | 517055 | 181959 | -0.314100 | 51.52443 | b2200ae0-425c-441f-88f8-b3ad3afc2152 | POLYGON ((515485.448 185498.141, 517101.131 18... | |
| 272 | 273 | E09000010 | Enfield | 532831 | 196198 | -0.081440 | 51.64890 | 53c0b28d-45c0-462e-96ff-dd23c7f8cead | POLYGON ((532542.111 200754.904, 534069.312 20... | |
| 273 | 274 | E09000011 | Greenwich | 542507 | 175878 | 0.050093 | 51.46394 | c559fa29-c300-4d10-8c1f-c0ea59815fa1 | MULTIPOLYGON (((537775.233 177557.193, 537679.... | |
| 274 | 275 | E09000012 | Hackney | 534560 | 185787 | -0.060460 | 51.55493 | a41cf0fc-95ed-4823-a9db-7b8bc60f421b | POLYGON ((537570.535 185494.637, 537638.712 18... | |
| 275 | 276 | E09000013 | Hammersmith and Fulham | 523867 | 177993 | -0.217350 | 51.48733 | fb263bb7-9972-416c-9e8c-fc6966c08221 | POLYGON ((523987.95 179648.788, 524495.91 1789... | |
| 276 | 277 | E09000014 | Haringey | 531260 | 189349 | -0.106700 | 51.58772 | a4407a53-4227-42ea-be81-5933bf73fc98 | POLYGON ((530582.539 191635.519, 530663.787 19... | |
| 277 | 278 | E09000015 | Harrow | 515359 | 189736 | -0.335990 | 51.59467 | 72e2ba10-bf08-4504-8775-6fd08d725dd7 | POLYGON ((518957.027 189354.542, 519091.743 18... | |
| 278 | 279 | E09000016 | Havering | 555032 | 187514 | 0.235368 | 51.56520 | ef6d5be3-a2f9-4ad8-8c35-5cdc37e0bf9e | POLYGON ((554025.008 194889.306, 556813.413 19... | |
| 279 | 280 | E09000017 | Hillingdon | 508168 | 183121 | -0.441790 | 51.53664 | ac5e6b28-6cc5-413b-b5b0-2d86048fe3f1 | POLYGON ((506743.924 191604.133, 506926.813 19... | |
| 280 | 281 | E09000018 | Hounslow | 512737 | 174959 | -0.378550 | 51.46239 | a53588f2-bf1c-41b5-83f7-d0e7419b35df | POLYGON ((519895.778 179006.316, 520259.425 17... | |
| 281 | 282 | E09000019 | Islington | 531160 | 184645 | -0.109900 | 51.54547 | 43a872fc-e401-45af-a2e6-3b2befc98837 | POLYGON ((533382.221 185149.793, 533460.932 18... | |
| 282 | 283 | E09000020 | Kensington and Chelsea | 525756 | 179054 | -0.189780 | 51.49645 | 29dc7a0f-a487-4156-a842-975bea2a337d | POLYGON ((524997.314 181304.14, 525054.697 181... | |
| 283 | 284 | E09000021 | Kingston upon Thames | 519508 | 167389 | -0.283680 | 51.39296 | 1e70f43d-4ddf-47dc-88bb-4df2efbfcafc | POLYGON ((521459.843 171478.421, 521826.419 16... | |
| 284 | 285 | E09000022 | Lambeth | 531118 | 175629 | -0.113850 | 51.46445 | 9143bbc4-6bda-4e17-8148-cae2813f694d | POLYGON ((532100.59 176565.764, 532344.012 176... | |
| 285 | 286 | E09000023 | Lewisham | 537888 | 173343 | -0.017340 | 51.44230 | 99f48b46-bb26-47d7-8c90-bab1eeba4425 | POLYGON ((537679.378 177411.633, 537413.712 17... | |
| 286 | 287 | E09000024 | Merton | 526068 | 169508 | -0.188690 | 51.41059 | 2e85b11a-12d0-45c2-862c-ffd0dce83b1a | POLYGON ((525905.297 172806.749, 525935.341 17... | |
| 287 | 288 | E09000025 | Newham | 540713 | 183346 | 0.027261 | 51.53150 | 70e80979-1178-4228-9ae5-2e8d09e17e69 | POLYGON ((542212.705 187007.618, 542916.164 18... | |
| 288 | 289 | E09000026 | Redbridge | 543512 | 189477 | 0.070085 | 51.58588 | 947652cf-8d04-498f-aeac-8cb34f1052d8 | POLYGON ((540036.316 194159.705, 541389.816 19... | |
| 289 | 290 | E09000027 | Richmond upon Thames | 519005 | 172650 | -0.289140 | 51.44035 | 533a2a77-3779-4660-b9de-90d93540ee21 | POLYGON ((522825.468 176226.515, 522800.098 17... | |
| 290 | 291 | E09000028 | Southwark | 533945 | 175869 | -0.073090 | 51.46595 | 7d09d625-212a-4819-9b12-36c8d8d2b697 | POLYGON ((533994.516 179939.606, 533814.438 17... | |
| 291 | 292 | E09000029 | Sutton | 527357 | 163639 | -0.172270 | 51.35755 | 1b5d57bc-1cb5-43e1-85ba-3bb45da0b7cc | POLYGON ((527423.64 167442.817, 527757.283 167... | |
| 292 | 293 | E09000030 | Tower Hamlets | 536340 | 181452 | -0.036480 | 51.51555 | 54f82e61-dc15-42cb-b777-681b4326f855 | POLYGON ((536480.759 184698.334, 536779.206 18... | |
| 293 | 294 | E09000031 | Waltham Forest | 537328 | 190278 | -0.018800 | 51.59462 | 97cd624f-2c02-4f12-a78e-7aedc777673f | POLYGON ((539923.888 193889.058, 539562.889 19... | |
| 294 | 295 | E09000032 | Wandsworth | 525152 | 174138 | -0.200220 | 51.45240 | 9c51587a-4315-449d-bcc7-e65625e402f7 | POLYGON ((528637.184 175213.943, 528758.922 17... | |
| 295 | 296 | E09000033 | Westminster | 528268 | 180871 | -0.152950 | 51.51222 | a52ff0f8-4ac0-4417-8338-01be3cbb516a | POLYGON ((526773.283 183663.262, 527373.359 18... |
gdf_uk_london.plot(figsize=(6, 6), edgecolor='grey', color='skyblue', alpha=0.7, linewidth=0.4)
<Axes: >
# We can check the CRS of the London local authority boundaries again.
gdf_uk_london.crs == gdf_ccz.crs
True
Intersection
In this case, we would like to create a new layer that contains only the areas of the LAs in London that are within the CCZ boundary. This is done by performing an intersection operation between the two geo-dfs (two layers).
# Perform intersection operation between London LA boundaries and CCZ boundary.
gdf_ccz_la = gpd.overlay(gdf_ccz, gdf_uk_london, how='intersection')
# We can observe that there are 8 LAs in London that are within the CCZ boundary (8 rows in GeoDataFrame), and we generate 8 new areas (zones).)
gdf_ccz_la
| OBJECTID | BOUNDARY | Shape_Area | FID | LAD24CD | LAD24NM | LAD24NMW | BNG_E | BNG_N | LONG | LAT | GlobalID | geometry | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | 1 | CSS Area | 21.375571 | 264 | E09000001 | City of London | 532382 | 181358 | -0.09352 | 51.51564 | 741710fd-03e1-4b41-8645-7ebcfc5961ac | POLYGON ((533743.557 181237.75, 533747.759 181... | |
| 1 | 1 | CSS Area | 21.375571 | 270 | E09000007 | Camden | 527491 | 184283 | -0.16291 | 51.54305 | 88f3f650-53ac-434d-883e-6235b48d14c4 | POLYGON ((528914.128 182173.503, 528917.252 18... | |
| 2 | 1 | CSS Area | 21.375571 | 275 | E09000012 | Hackney | 534560 | 185787 | -0.06046 | 51.55493 | a41cf0fc-95ed-4823-a9db-7b8bc60f421b | POLYGON ((532941.601 182534.749, 532960.103 18... | |
| 3 | 1 | CSS Area | 21.375571 | 282 | E09000019 | Islington | 531160 | 184645 | -0.10990 | 51.54547 | 43a872fc-e401-45af-a2e6-3b2befc98837 | POLYGON ((531582.254 183032.797, 531584.653 18... | |
| 4 | 1 | CSS Area | 21.375571 | 285 | E09000022 | Lambeth | 531118 | 175629 | -0.11385 | 51.46445 | 9143bbc4-6bda-4e17-8148-cae2813f694d | POLYGON ((531750.948 178636.445, 531734.903 17... | |
| 5 | 1 | CSS Area | 21.375571 | 291 | E09000028 | Southwark | 533945 | 175869 | -0.07309 | 51.46595 | 7d09d625-212a-4819-9b12-36c8d8d2b697 | POLYGON ((533584.147 180067.345, 533558.653 18... | |
| 6 | 1 | CSS Area | 21.375571 | 293 | E09000030 | Tower Hamlets | 536340 | 181452 | -0.03648 | 51.51555 | 54f82e61-dc15-42cb-b777-681b4326f855 | MULTIPOLYGON (((533533.852 182103.403, 533568.... | |
| 7 | 1 | CSS Area | 21.375571 | 296 | E09000033 | Westminster | 528268 | 180871 | -0.15295 | 51.51222 | a52ff0f8-4ac0-4417-8338-01be3cbb516a | POLYGON ((530031.102 178265.801, 530007.101 17... |
# We can plot the new 8 layers using the plot method.
# We can observe that some LA boundaries have been cut by the CCZ boundary.
gdf_ccz_la.plot(figsize=(6, 6), edgecolor='grey', color='orange', alpha=0.7, linewidth=0.4)
<Axes: >
Union
In this case, we would like to create a new union layer that consists of Camden and CCZ. This is done by performing a union operation between the two geo-dfs (two layers).
# Select Camden LA boundary from the London LA boundaries.
gdf_camden = gdf_uk_london[gdf_uk_london['LAD24NM'] == 'Camden']
# plot the Camden LA boundary.
gdf_camden.plot(figsize=(6, 6), edgecolor='grey', color='skyblue', alpha=0.7, linewidth=0.4)
<Axes: >
# Perform union operation between Camden LA boundary and CCZ boundary.
gdf_union = gpd.overlay(gdf_camden, gdf_ccz, how='union')
# We can observe that there are 3 rows in the new GeoDataFrame.
gdf_union
| FID | LAD24CD | LAD24NM | LAD24NMW | BNG_E | BNG_N | LONG | LAT | GlobalID | OBJECTID | BOUNDARY | Shape_Area | geometry | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | 270.0 | E09000007 | Camden | 527491.0 | 184283.0 | -0.16291 | 51.54305 | 88f3f650-53ac-434d-883e-6235b48d14c4 | 1.0 | CSS Area | 21.375571 | POLYGON ((530916.914 182414.861, 531556.915 18... | |
| 1 | 270.0 | E09000007 | Camden | 527491.0 | 184283.0 | -0.16291 | 51.54305 | 88f3f650-53ac-434d-883e-6235b48d14c4 | NaN | NaN | NaN | POLYGON ((529701.341 185186.66, 529818.726 184... | |
| 2 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | 1.0 | CSS Area | 21.375571 | POLYGON ((531582.254 183032.797, 531584.653 18... |
We can observe that the new union zone consists of three parts/ areas:
Camden area that is not in CCZ.
CCZ that is not in Camden LA boundary.
The intersected area that is both in Camden LA boundary and CCZ boundary.
# plot each area in the new union zone.
for i in range(len(gdf_union)):
gdf_union.iloc[[i]].plot(figsize=(3, 3), edgecolor='grey', color='orange', alpha=0.7, linewidth=0.4)
Symmetric difference
In this case, we would like to create a new layer that consists of the areas of Camden and CCZ that are not in common. This is done by performing a symmetric difference operation between the two geo-dfs (two layers).
# Perform a symmetric difference operation between Camden LA boundary and CCZ boundary.
gdf_sym_diff = gpd.overlay(gdf_camden, gdf_ccz, how='symmetric_difference')
# We can observe that there are 2 rows in the new GeoDataFrame.
gdf_sym_diff
| FID | LAD24CD | LAD24NM | LAD24NMW | BNG_E | BNG_N | LONG | LAT | GlobalID | OBJECTID | BOUNDARY | Shape_Area | geometry | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | 270.0 | E09000007 | Camden | 527491.0 | 184283.0 | -0.16291 | 51.54305 | 88f3f650-53ac-434d-883e-6235b48d14c4 | NaN | NaN | NaN | POLYGON ((529701.341 185186.66, 529818.726 184... | |
| 1 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | 1.0 | CSS Area | 21.375571 | POLYGON ((531582.254 183032.797, 531584.653 18... |
We can observe that the new zone consists of two parts/ areas:
Camden area that is not in CCZ.
CCZ area that is not in Camden LA boundary.
This means that symmetric difference only returns the two areas (which dorpping the intersected area) when compared to the union operation.
# plot each area in the new zone.
for i in range(len(gdf_sym_diff)):
gdf_sym_diff.iloc[[i]].plot(figsize=(3, 3), edgecolor='grey', color='orange', alpha=0.7, linewidth=0.4)
Difference
In this case, we would like to create a new layer that consists of the areas of Camden that are not in CCZ. This is done by performing a different operation between the two geo-dfs (two layers).
# Perform a difference operation between Camden LA boundary and CCZ boundary.
gdf_diff_1 = gpd.overlay(gdf_camden, gdf_ccz, how='difference')
# plot the new zone.
gdf_diff_1.plot(figsize=(3, 3), edgecolor='grey', color='orange', alpha=0.7, linewidth=0.4)
<Axes: >
If we change the order of the gdfs in the fuction, we will get another new layrer that consists of the areas of CCZ that are not in Camden.
# Perform a difference operation between CCZ boundary and Camden LA boundary.
gdf_diff_2 = gpd.overlay(gdf_ccz, gdf_camden, how='difference')
# plot the new zone.
gdf_diff_2.plot(figsize=(3, 3), edgecolor='grey', color='orange', alpha=0.7, linewidth=0.4)
<Axes: >
There is a related function in geopandas called clip, check the documentation at here (click).
2.1.2 Dissolve/aggregation#
Data aggregation is a process of combining multiple features into a single feature based on a common attribute. This is useful for simplifying the data and reducing the number of features in a GeoDataFrame. The dissolve method in Geopandas is used to perform data aggregation for geometric data.
We continue to use the London local authority boundaries and the CCZ boundary. Frist, We will dissolve the 33 London local authority boundaries to one whole London boundary using the dissolve method.
# Dissolve the London local authority boundaries to one whole London boundary.
gdf_london_bound = gdf_uk_london.dissolve()
# We can observe that there is only one row in the new GeoDataFrame, we need to change the other attributes or just select the geometry column in the new GeoDataFrame as well.
gdf_london_bound
| geometry | FID | LAD24CD | LAD24NM | LAD24NMW | BNG_E | BNG_N | LONG | LAT | GlobalID | |
|---|---|---|---|---|---|---|---|---|---|---|
| 0 | POLYGON ((528007.109 160148.702, 528072.716 16... | 264 | E09000001 | City of London | 532382 | 181358 | -0.09352 | 51.51564 | 741710fd-03e1-4b41-8645-7ebcfc5961ac |
# plot the new London boundary.
gdf_london_bound.plot(figsize=(6, 6), edgecolor='grey', color='skyblue', alpha=0.7, linewidth=0.4)
<Axes: >
Second, as we have already known that some LAs have the CCZ but some are not, so we can dissolve the LAs to two big boundaries:
LAs that are intersected with (or have) CCZ.
LAs that are not intersected with (or do not have) CCZ.
# You need to recap the intersection operation in the previous section as we got 8 LAs that are intersected with CCZ.
# The list of LAs that are intersected with CCZ.
la_ccz_list = gdf_ccz_la['LAD24NM'].unique()
# we need to create a new column in the London local authority boundaries to indicate whether the LA is intersected with CCZ or not.
gdf_uk_london['intersected'] = gdf_uk_london['LAD24NM'].apply(lambda x: 'intersected' if x in la_ccz_list else 'not_intersected')
# check the results
gdf_uk_london['intersected'].value_counts()
intersected
not_intersected 25
intersected 8
Name: count, dtype: int64
# Dissolve the London local authority boundaries based on the new column 'intersected'.
gdf_london_la_ccz = gdf_uk_london.dissolve(by='intersected')
# We can observe that there are 2 rows (two areas) in the new GeoDataFrame.
gdf_london_la_ccz
| geometry | FID | LAD24CD | LAD24NM | LAD24NMW | BNG_E | BNG_N | LONG | LAT | GlobalID | |
|---|---|---|---|---|---|---|---|---|---|---|
| intersected | ||||||||||
| intersected | MULTIPOLYGON (((531786.297 170988.473, 531320.... | 264 | E09000001 | City of London | 532382 | 181358 | -0.093520 | 51.51564 | 741710fd-03e1-4b41-8645-7ebcfc5961ac | |
| not_intersected | POLYGON ((528007.109 160148.702, 528072.716 16... | 265 | E09000002 | Barking and Dagenham | 547757 | 185111 | 0.129479 | 51.54556 | a2f59957-115c-478b-8c27-5162ee915dc7 |
# select the necessary columns in the new GeoDataFrame.
gdf_london_la_ccz = gdf_london_la_ccz[['geometry',]].reset_index()
gdf_london_la_ccz
| intersected | geometry | |
|---|---|---|
| 0 | intersected | MULTIPOLYGON (((531786.297 170988.473, 531320.... |
| 1 | not_intersected | POLYGON ((528007.109 160148.702, 528072.716 16... |
# plot the new GeoDataFrame.
gdf_london_la_ccz.plot(figsize=(6, 6), edgecolor='grey', color=['orange', 'skyblue'], alpha=0.7, linewidth=0.4)
<Axes: >
2.1.3 Buffer analysis#
A buffer is a zone around a geometric object that is used to create a new area with a specified distance from the original feature. The buffer method in Geopandas is used to create a buffer around a point, line, or polygon. Buffer analysis is popular and useful in many applications, such as environmental studies, urban planning, and transportation analysis.
We continue to stick to the London areas, and we introduce two datasets in this section: First is the London cycle routes, which is a LineString layer. The second is the London Underground station locations, which is a point layer. We will create a buffer around the cycle routes and the underground stations to create new buffer areas for analysis.
Buffer of linestring
# Read the London cycle routes in geojson format.
gdf_cycle_routes = gpd.read_file("data/Cycle_Routes.geojson")
# We can observe that there are 166 cycle routes (or segments).
gdf_cycle_routes
| LABEL | PROGRAMME | ROUTE_NAME | ROUTE | MILESTONE | STATUS | PUBLIC_ | ROUTE_LENGTH_KM | PROGRAMME_UPDATED | OBJECTID | Shape__Length | geometry | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | C38 | Cycleways | Finsbury Park to Highbury Fields | Islington to Finsbury | (SG2) Option Selection | Feasibility | Yes | 0.566 | 2023-11-21 00:00:00+00:00 | 1991 | 565.899062 | LINESTRING Z (-0.11025 51.529 0, -0.1103 51.52... |
| 1 | C48 | Cycleways | Brixton to Clapham High Street | Brixton to Clapham High Street | Complete | Complete | Yes | 1.315 | 2023-11-21 00:00:00+00:00 | 1992 | 1315.182747 | LINESTRING Z (-0.11475 51.46328 0, -0.11458 51... |
| 2 | C44 | Cycleways | Pembridge Square to Meanwhile Gardens | Pembridge Square to Meanwhile Gardens | Complete | Complete | Yes | 2.296 | 2023-11-21 00:00:00+00:00 | 1993 | 2295.837258 | MULTILINESTRING Z ((-0.20319 51.51629 0, -0.20... |
| 3 | C43 | Future Routes | Hyde Park to Paddington | Hyde Park to Paddington | (SG4) Detailed Design | Feasibility | Yes | 0.757 | 2023-11-21 00:00:00+00:00 | 1994 | 757.198071 | MULTILINESTRING Z ((-0.16325 51.51393 0, -0.16... |
| 4 | C41 | Cycleways | Euston to Holborn | Euston to Holborn | Complete | Complete | Yes | 1.181 | 2023-11-21 00:00:00+00:00 | 1995 | 1180.878708 | LINESTRING Z (-0.12373 51.52611 0, -0.12331 51... |
| ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| 161 | C10 | Cycleways | Blomsbury to Embankment | Blomsbury to Embankment | Complete | Complete | Yes | 1.421 | 2023-11-21 00:00:00+00:00 | 2152 | 1420.613731 | MULTILINESTRING Z ((-0.11858 51.50975 0, -0.11... |
| 162 | C | Cycleways | Elephant and Castle to Hampstead | Castlehaven Grafton Road | Complete | Complete | Yes | 1.833 | 2023-11-21 00:00:00+00:00 | 2153 | 1832.819766 | LINESTRING Z (-0.15988 51.55558 0, -0.15913 51... |
| 163 | C40 | Cycleways | Brentford to Twickenham | Brentford to Twickenham | Complete | Complete | Yes | 4.291 | 2023-11-21 00:00:00+00:00 | 2154 | 4291.196598 | LINESTRING Z (-0.33154 51.45099 0, -0.33132 51... |
| 164 | C4 | Cycleways | London Bridge to Rotherhithe Roundabout | Rotherhithe Roundabout to Lewisham | (SG5) Delivery | In Progress | Yes | 1.335 | 2023-11-21 00:00:00+00:00 | 2155 | 1335.083915 | LINESTRING Z (-0.04217 51.49002 0, -0.04295 51... |
| 165 | C39 | Cycleways | Kensington High St to Shepherds Bush | Kensington High St to Shepherds Bush | Complete | Complete | Yes | 1.151 | 2023-11-21 00:00:00+00:00 | 2156 | 1151.249368 | LINESTRING Z (-0.20691 51.4963 0, -0.20774 51.... |
166 rows × 12 columns
# Please note that the rounte name is not unique, which means that the same route name can be used in different linestring segments.
# For example, the route name 'Waterloo to Clapham' is used in 6 segments.
gdf_cycle_routes.ROUTE_NAME.value_counts()
ROUTE_NAME
Hammersmith to Hounslow 10
Waterloo to Clapham 6
Elephant and Castle to Hampstead 5
Finsbury Park to Highbury Fields 3
Victoria Park to Barkingside 3
..
Grand Union Canal 1
Haggerston to Dalston 1
LSP Kings Cross to Camden Road 1
Peckham Rye Links 1
Kensington High St to Shepherds Bush 1
Name: count, Length: 116, dtype: int64
# We transfer the CRS of the cycle routes from WGS 84 to OSGB 1936 / British National Grid.
gdf_cycle_routes = gdf_cycle_routes.to_crs(epsg=27700)
# We can plot the cycle routes in London, we can add the whole London boundary to the plot as well.
from matplotlib import pyplot as plt
fig, ax = plt.subplots(figsize=(6, 6))
gdf_london_bound.plot(ax=ax, edgecolor='grey', color='skyblue', alpha=0.4, linewidth=0.4)
gdf_cycle_routes.plot(ax=ax, edgecolor='grey', color='green', alpha=0.7, linewidth=1)
ax.set_axis_off()
# We only select one route OBJECTID is 2096 from the 'Waterloo to Clapham' route name.
gdf_cr_s = gdf_cycle_routes[gdf_cycle_routes['OBJECTID'] == 2096]
gdf_cr_s
| LABEL | PROGRAMME | ROUTE_NAME | ROUTE | MILESTONE | STATUS | PUBLIC_ | ROUTE_LENGTH_KM | PROGRAMME_UPDATED | OBJECTID | Shape__Length | geometry | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 105 | C5 | Cycleways | Waterloo to Clapham | Waterloo to Clapham | Complete | Complete | Yes | 5.814 | 2023-11-21 00:00:00+00:00 | 2096 | 5814.364404 | LINESTRING Z (528800.09 174090.413 0, 528776.0... |
# We can plot the selected route.
gdf_cr_s.plot(edgecolor='grey', color='green', alpha=1, linewidth=3)
<Axes: >
# Then we create a buffer around the selected route with a distance of 500 meters (as we have transferred the CRS to OSGB so the measurement unit is metre).
cr_s_buffer_500 = gdf_cr_s.buffer(500)
# we can observe that the buffer is a polygon layer.
cr_s_buffer_500
105 POLYGON ((528187.268 174633.775, 528216.987 17...
dtype: geometry
# the output is geoseries not geodataframe
type(cr_s_buffer_500)
geopandas.geoseries.GeoSeries
# Plot the route and the buffer.
fig, ax = plt.subplots(figsize=(6, 6))
gdf_cr_s.plot(ax=ax, edgecolor='grey', color='green', alpha=1, linewidth=3)
cr_s_buffer_500.plot(ax=ax, edgecolor='grey', color='skyblue', alpha=0.4, linewidth=0.4)
<Axes: >
Buffer of Point
# We read the London Underground station locations in geojson format.
gdf_underground = gpd.read_file("data/Underground_Stations.geojson")
# We can observe that there are 273 underground stations in London.
gdf_underground.head(10)
| OBJECTID | NAME | LINES | ATCOCODE | MODES | ACCESSIBILITY | NIGHT_TUBE | NETWORK | DATASET_LAST_UPDATED | FULL_NAME | geometry | |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | 111 | St. Paul's | Central | 940GZZLUSPU | bus, tube | Not Accessible | Yes | London Underground | 2021-11-29 00:00:00+00:00 | St. Paul's station | POINT Z (-0.09749 51.51495 0) |
| 1 | 112 | Mile End | District, Hammersmith & City, Central | 940GZZLUMED | bus, tube | Partially Accessible - Interchange Only | Yes | London Underground | 2021-11-29 00:00:00+00:00 | Mile End station | POINT Z (-0.03374 51.52524 0) |
| 2 | 113 | Bethnal Green | Central | 940GZZLUBLG | bus, tube | Not Accessible | Yes | London Underground | 2021-11-29 00:00:00+00:00 | Bethnal Green station | POINT Z (-0.05466 51.52724 0) |
| 3 | 114 | Leyton | Central | 940GZZLULYN | bus, tube | Not Accessible | Yes | London Underground | 2021-11-29 00:00:00+00:00 | Leyton station | POINT Z (-0.00546 51.55661 0) |
| 4 | 115 | Snaresbrook | Central | 940GZZLUSNB | bus, tube | Not Accessible | Yes | London Underground | 2021-11-29 00:00:00+00:00 | Snaresbrook station | POINT Z (0.02142 51.58068 0) |
| 5 | 116 | Leytonstone | Central | 940GZZLULYS | bus, tube | Not Accessible | Yes | London Underground | 2021-11-29 00:00:00+00:00 | Leytonstone station | POINT Z (0.00821 51.56832 0) |
| 6 | 117 | Wanstead | Central | 940GZZLUWSD | bus, tube | Not Accessible | Yes | London Underground | 2021-11-29 00:00:00+00:00 | Wanstead station | POINT Z (0.02865 51.5756 0) |
| 7 | 118 | South Woodford | Central | 940GZZLUSWF | bus, tube | Partially Accessible | Yes | London Underground | 2021-11-29 00:00:00+00:00 | South Woodford station | POINT Z (0.02739 51.59189 0) |
| 8 | 119 | Newbury Park | Central | 940GZZLUNBP | tube, bus | Not Accessible | Yes | London Underground | 2021-11-29 00:00:00+00:00 | Newbury Park station | POINT Z (0.08995 51.57571 0) |
| 9 | 120 | Barkingside | Central | 940GZZLUBKE | tube, bus | Partially Accessible | Yes | London Underground | 2021-11-29 00:00:00+00:00 | Barkingside station | POINT Z (0.08865 51.5857 0) |
# We need to transfer the CRS of the underground stations from WGS 84 to OSGB 1936 / British National Grid.
gdf_underground = gdf_underground.to_crs(epsg=27700)
# Plot the underground stations in London, we can add the whole London boundary to the plot as well.
# Some underground stations are located outside the London Boundary.
fig, ax = plt.subplots(figsize=(6, 6))
gdf_london_bound.plot(ax=ax, edgecolor='grey', color='skyblue', alpha=0.4, linewidth=0.4)
gdf_underground.plot(ax=ax, edgecolor='grey', color='red', alpha=0.7, lw=0.5, markersize=5)
ax.set_axis_off()
# We select the stations of the 'Victoria' line.
# Please note we cannot use the '==' to select the stations of the 'Victoria' line as some stations are in multiple underground lines.
gdf_underground_victoria = gdf_underground[gdf_underground['LINES'].str.contains('Victoria')]
# We can observe that there are 16 underground stations in the 'Victoria' line.
gdf_underground_victoria
| OBJECTID | NAME | LINES | ATCOCODE | MODES | ACCESSIBILITY | NIGHT_TUBE | NETWORK | DATASET_LAST_UPDATED | FULL_NAME | geometry | |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 56 | 167 | King's Cross St. Pancras | Metropolitan, Northern, Piccadilly, Circle, Vi... | 940GZZLUKSX | tube | Fully Accessible | Yes | London Underground | 2021-11-29 00:00:00+00:00 | King's Cross St. Pancras station | POINT Z (530174.81 182874.778 0) |
| 74 | 185 | Victoria | District, Circle, Victoria | 940GZZLUVIC | tube | Partially Accessible | Yes | London Underground | 2021-11-29 00:00:00+00:00 | Victoria station | POINT Z (528998.784 179129.938 0) |
| 75 | 186 | Brixton | Victoria | 940GZZLUBXN | tube | Fully Accessible | Yes | London Underground | 2021-11-29 00:00:00+00:00 | Brixton station | POINT Z (531052.394 175428.659 0) |
| 76 | 187 | Pimlico | Victoria | 940GZZLUPCO | tube, bus | Not Accessible | Yes | London Underground | 2021-11-29 00:00:00+00:00 | Pimlico station | POINT Z (529670.659 178332.6 0) |
| 77 | 188 | Vauxhall | Victoria | 940GZZLUVXL | tube | Not Accessible | Yes | London Underground | 2021-11-29 00:00:00+00:00 | Vauxhall station | POINT Z (530336.807 177973.008 0) |
| 78 | 189 | Warren Street | Northern, Victoria | 940GZZLUWRR | tube, bus | Not Accessible | Yes | London Underground | 2021-11-29 00:00:00+00:00 | Warren Street station | POINT Z (529248.757 182266.037 0) |
| 99 | 210 | Oxford Circus | Central, Bakerloo, Victoria | 940GZZLUOXC | tube, bus | Partially Accessible - Interchange Only | Yes | London Underground | 2021-11-29 00:00:00+00:00 | Oxford Circus station | POINT Z (529046.627 181236.34 0) |
| 131 | 242 | Highbury & Islington | Victoria | 940GZZLUHAI | tube | Partially Accessible | Yes | London Underground | 2021-11-29 00:00:00+00:00 | Highbury & Islington station | POINT Z (531583.282 184873.938 0) |
| 132 | 243 | Blackhorse Road | Victoria | 940GZZLUBLR | tube | Not Accessible | Yes | London Underground | 2021-11-29 00:00:00+00:00 | Blackhorse Road station | POINT Z (535760.641 189370.301 0) |
| 133 | 244 | Tottenham Hale | Victoria | 940GZZLUTMH | tube | Fully Accessible | Yes | London Underground | 2021-11-29 00:00:00+00:00 | Tottenham Hale station | POINT Z (534484.464 189470.718 0) |
| 174 | 285 | Euston | Northern, Victoria | 940GZZLUEUS | tube | Partially Accessible | Yes | London Underground | 2021-11-29 00:00:00+00:00 | Euston station | POINT Z (529498.332 182668.253 0) |
| 178 | 289 | Walthamstow Central | Victoria | 940GZZLUWWL | tube | Not Accessible | Yes | London Underground | 2021-11-29 00:00:00+00:00 | Walthamstow Central station | POINT Z (537176.489 188994.337 0) |
| 182 | 293 | Green Park | Piccadilly, Victoria, Jubilee | 940GZZLUGPK | bus, tube | Fully Accessible | Yes | London Underground | 2021-11-29 00:00:00+00:00 | Green Park station | POINT Z (529007.243 180294.838 0) |
| 183 | 294 | Finsbury Park | Piccadilly, Victoria | 940GZZLUFPK | tube | Partially Accessible - Interchange Only | Yes | London Underground | 2021-11-29 00:00:00+00:00 | Finsbury Park station | POINT Z (531329.899 186775.337 0) |
| 184 | 295 | Stockwell | Northern, Victoria | 940GZZLUSKW | bus, tube | Partially Accessible - Interchange Only | Yes | London Underground | 2021-11-29 00:00:00+00:00 | Stockwell station | POINT Z (530460.348 176432.891 0) |
| 268 | 483 | Seven Sisters | Victoria | 940GZZLUSVS | tube | Not Accessible | Yes | London Underground | 2021-11-29 00:00:00+00:00 | Seven Sisters station | POINT Z (533642.911 188930.916 0) |
# We can plot the selected stations.
fig, ax = plt.subplots(figsize=(6, 6))
gdf_london_bound.plot(ax=ax, edgecolor='grey', color='skyblue', alpha=0.4, linewidth=0.4)
gdf_underground_victoria.plot(ax=ax, edgecolor='grey', color='red', alpha=0.7, lw=0.5, markersize=5)
<Axes: >
# We create a buffer around the selected stations with a distance of 500 meters.
underground_victoria_buffer = gdf_underground_victoria.buffer(500)
# We can observe that the buffer is a polygon layer.
underground_victoria_buffer
56 POLYGON ((530674.81 182874.778, 530672.403 182...
74 POLYGON ((529498.784 179129.938, 529496.377 17...
75 POLYGON ((531552.394 175428.659, 531549.987 17...
76 POLYGON ((530170.659 178332.6, 530168.251 1782...
77 POLYGON ((530836.807 177973.008, 530834.4 1779...
78 POLYGON ((529748.757 182266.037, 529746.35 182...
99 POLYGON ((529546.627 181236.34, 529544.219 181...
131 POLYGON ((532083.282 184873.938, 532080.874 18...
132 POLYGON ((536260.641 189370.301, 536258.233 18...
133 POLYGON ((534984.464 189470.718, 534982.056 18...
174 POLYGON ((529998.332 182668.253, 529995.925 18...
178 POLYGON ((537676.489 188994.337, 537674.081 18...
182 POLYGON ((529507.243 180294.838, 529504.835 18...
183 POLYGON ((531829.899 186775.337, 531827.492 18...
184 POLYGON ((530960.348 176432.891, 530957.94 176...
268 POLYGON ((534142.911 188930.916, 534140.504 18...
dtype: geometry
# Plot the underground stations and the buffers.
fig, ax = plt.subplots(figsize=(6, 6))
gdf_underground_victoria.plot(ax=ax, edgecolor='grey', color='red', alpha=1, lw=0.5, markersize=5)
underground_victoria_buffer.plot(ax=ax, edgecolor='grey', color='skyblue', alpha=0.4, linewidth=0.4)
ax.set_axis_off()
2.2 Spatial Join#
Like the merge function in Pandas, Geopandas Spatial join is a process of combining two GeoDataFrames based on their spatial relationship. This is useful for analyzing the relationship between different layers and types of geospatial data. For example, we can use spatial join to combine a large dataset of points with polygons to find out which points are within which polygons.
As part of data merging techniques in Geopandas, you can find more info on this page. Please note that the spatial join is different from the overlay operation, which creates a new layer based on the intersection of two layers. The spatial join only combines the attributes of the two layers based on their spatial relationship.
The default spatial index in GeoPandas currently supports the following values for predicate parameter which are defined in the Shapely documentation:
Method |
Description |
|---|---|
|
Returns all geometries that intersect with the other geometry. |
|
Returns all geometries that contain the other geometry. |
|
Returns all geometries that are within the other geometry. Inverse of |
|
Returns all geometries that cross the other geometry (share some but not all points). |
|
Returns all geometries that touch (are adjacent to) the other geometry. |
how parameter in spatial join is same as the Pandas which control which keys to include in the resulting DataFrame.
Merge Method |
SQL Join Name |
Description |
|---|---|---|
left |
LEFT OUTER JOIN |
Use keys from left frame only |
right |
RIGHT OUTER JOIN |
Use keys from right frame only |
outer |
FULL OUTER JOIN |
Use union of keys from both frames |
inner |
INNER JOIN |
Use intersection of keys from both frames |
cross |
CROSS JOIN |
Create the cartesian product of rows of both frames |
Here, we will use the London dataset use to demonstrate the spatial join operation. First, we will perform a spatial join between the CCZ zone and London Underground stations to find out which underground stations are within the CCZ zone.
# Perform a spatial join between London Underground stations and CCZ zone.
gdf_ccz_underground = gpd.sjoin(gdf_underground, gdf_ccz, how='inner', predicate='within')
Please note that how parameter is set to ‘inner,’ which means that only the stations that are within the CCZ area will be returned.
The predicate parameter is set to within which means that only the stations (left gdf) that are within the CCZ (right gdf) will be returned.
If we set how parameter to left (LEFT OUTER JOIN), all the stations will be returned, but only the stations that are within the CCZ will have the CCZ attributes.
If we set how parameter to right (RIGHT OUTER JOIN), all the CCZ zones will be returned, but only the CCZ that has the underground stations will have the underground station attributes.
# We can observe that there are 37 underground stations that are within the CCZ zone.
gdf_ccz_underground
| OBJECTID_left | NAME | LINES | ATCOCODE | MODES | ACCESSIBILITY | NIGHT_TUBE | NETWORK | DATASET_LAST_UPDATED | FULL_NAME | geometry | index_right | OBJECTID_right | BOUNDARY | Shape_Area | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | 111 | St. Paul's | Central | 940GZZLUSPU | bus, tube | Not Accessible | Yes | London Underground | 2021-11-29 00:00:00+00:00 | St. Paul's station | POINT Z (532108.364 181274.192 0) | 0 | 1 | CSS Area | 21.375571 |
| 36 | 147 | Leicester Square | Piccadilly, Northern | 940GZZLULSQ | tube, bus | Not Accessible | Yes | London Underground | 2021-11-29 00:00:00+00:00 | Leicester Square station | POINT Z (529980.442 180824.485 0) | 0 | 1 | CSS Area | 21.375571 |
| 37 | 148 | Covent Garden | Piccadilly | 940GZZLUCGN | tube | Not Accessible | Yes | London Underground | 2021-11-29 00:00:00+00:00 | Covent Garden station | POINT Z (530250.619 181025.007 0) | 0 | 1 | CSS Area | 21.375571 |
| 38 | 149 | Russell Square | Piccadilly | 940GZZLURSQ | tube, bus | Not Accessible | Yes | London Underground | 2021-11-29 00:00:00+00:00 | Russell Square station | POINT Z (530229.106 182127.727 0) | 0 | 1 | CSS Area | 21.375571 |
| 46 | 157 | Temple | District, Circle | 940GZZLUTMP | tube, bus | Not Accessible | No | London Underground | 2021-11-29 00:00:00+00:00 | Temple station | POINT Z (530958.673 180802.833 0) | 0 | 1 | CSS Area | 21.375571 |
| 47 | 158 | Blackfriars | District, Circle | 940GZZLUBKF | tube | Fully Accessible | No | London Underground | 2021-11-29 00:00:00+00:00 | Blackfriars station | POINT Z (531693.89 180893.089 0) | 0 | 1 | CSS Area | 21.375571 |
| 48 | 159 | Mansion House | District, Circle | 940GZZLUMSH | tube, bus | Not Accessible | No | London Underground | 2021-11-29 00:00:00+00:00 | Mansion House station | POINT Z (532354.181 180931.566 0) | 0 | 1 | CSS Area | 21.375571 |
| 49 | 160 | Cannon Street | District, Circle | 940GZZLUCST | tube | Partially Accessible | No | London Underground | 2021-11-29 00:00:00+00:00 | Cannon Street station | POINT Z (532611.488 180900.068 0) | 0 | 1 | CSS Area | 21.375571 |
| 50 | 161 | Tower Hill | District, Circle | 940GZZLUTWH | tube | Not Accessible | No | London Underground | 2021-11-29 00:00:00+00:00 | Tower Hill station | POINT Z (533579.46 180755.388 0) | 0 | 1 | CSS Area | 21.375571 |
| 51 | 162 | Aldgate | Metropolitan, Circle | 940GZZLUALD | bus, tube | Not Accessible | No | London Underground | 2021-11-29 00:00:00+00:00 | Aldgate station | POINT Z (533613.164 181262.299 0) | 0 | 1 | CSS Area | 21.375571 |
| 52 | 163 | Liverpool Street | Metropolitan, Central, Circle, Hammersmith & City | 940GZZLULVT | tube | Partially Accessible | Yes | London Underground | 2021-11-29 00:00:00+00:00 | Liverpool Street station | POINT Z (533093.866 181566.922 0) | 0 | 1 | CSS Area | 21.375571 |
| 53 | 164 | Moorgate | Metropolitan, Northern, Circle, Hammersmith & ... | 940GZZLUMGT | tube | Not Accessible | No | London Underground | 2021-11-29 00:00:00+00:00 | Moorgate station | POINT Z (532667.838 181668.248 0) | 0 | 1 | CSS Area | 21.375571 |
| 54 | 165 | Barbican | Metropolitan, Circle, Hammersmith & City | 940GZZLUBBN | tube, bus | Not Accessible | No | London Underground | 2021-11-29 00:00:00+00:00 | Barbican station | POINT Z (532004.215 181856.333 0) | 0 | 1 | CSS Area | 21.375571 |
| 55 | 166 | Farringdon | Metropolitan, Circle, Hammersmith & City | 940GZZLUFCN | tube | Fully Accessible | No | London Underground | 2021-11-29 00:00:00+00:00 | Farringdon station | POINT Z (531560.011 181873.93 0) | 0 | 1 | CSS Area | 21.375571 |
| 78 | 189 | Warren Street | Northern, Victoria | 940GZZLUWRR | tube, bus | Not Accessible | Yes | London Underground | 2021-11-29 00:00:00+00:00 | Warren Street station | POINT Z (529248.757 182266.037 0) | 0 | 1 | CSS Area | 21.375571 |
| 92 | 203 | Marble Arch | Central | 940GZZLUMBA | tube, bus | Not Accessible | Yes | London Underground | 2021-11-29 00:00:00+00:00 | Marble Arch station | POINT Z (527960.144 181017.479 0) | 0 | 1 | CSS Area | 21.375571 |
| 93 | 204 | Bond Street | Central, Jubilee | 940GZZLUBND | tube, bus | Fully Accessible | Yes | London Underground | 2021-11-29 00:00:00+00:00 | Bond Street station | POINT Z (528490.686 181117.639 0) | 0 | 1 | CSS Area | 21.375571 |
| 98 | 209 | Bank | Waterloo & City, Northern, Central | 940GZZLUBNK | tube | Not Accessible | Yes | London Underground | 2021-11-29 00:00:00+00:00 | Bank station | POINT Z (532710.168 181119.901 0) | 0 | 1 | CSS Area | 21.375571 |
| 99 | 210 | Oxford Circus | Central, Bakerloo, Victoria | 940GZZLUOXC | tube, bus | Partially Accessible - Interchange Only | Yes | London Underground | 2021-11-29 00:00:00+00:00 | Oxford Circus station | POINT Z (529046.627 181236.34 0) | 0 | 1 | CSS Area | 21.375571 |
| 100 | 211 | Holborn | Central, Piccadilly | 940GZZLUHBN | tube, bus | Not Accessible | Yes | London Underground | 2021-11-29 00:00:00+00:00 | Holborn station | POINT Z (530512.074 181525.075 0) | 0 | 1 | CSS Area | 21.375571 |
| 101 | 212 | Chancery Lane | Central | 940GZZLUCHL | tube, bus | Not Accessible | Yes | London Underground | 2021-11-29 00:00:00+00:00 | Chancery Lane station | POINT Z (531123.959 181615.469 0) | 0 | 1 | CSS Area | 21.375571 |
| 118 | 229 | Goodge Street | Northern | 940GZZLUGDG | tube, bus | Not Accessible | Yes | London Underground | 2021-11-29 00:00:00+00:00 | Goodge Street station | POINT Z (529537.286 181836.596 0) | 0 | 1 | CSS Area | 21.375571 |
| 119 | 230 | Tottenham Court Road | Central, Northern | 940GZZLUTCR | bus, tube | Fully Accessible | Yes | London Underground | 2021-11-29 00:00:00+00:00 | Tottenham Court Road station | POINT Z (529815.394 181382.5 0) | 0 | 1 | CSS Area | 21.375571 |
| 148 | 259 | Embankment | District, Bakerloo, Northern, Circle | 940GZZLUEMB | tube | Not Accessible | Yes | London Underground | 2021-11-29 00:00:00+00:00 | Embankment station | POINT Z (530419.337 180395.875 0) | 0 | 1 | CSS Area | 21.375571 |
| 157 | 268 | Piccadilly Circus | Bakerloo, Piccadilly | 940GZZLUPCC | bus, tube | Not Accessible | Yes | London Underground | 2021-11-29 00:00:00+00:00 | Piccadilly Circus station | POINT Z (529612.657 180665.533 0) | 0 | 1 | CSS Area | 21.375571 |
| 158 | 269 | Charing Cross | Bakerloo, Northern | 940GZZLUCHX | tube | Fully Accessible | Yes | London Underground | 2021-11-29 00:00:00+00:00 | Charing Cross station | POINT Z (530057.711 180378.385 0) | 0 | 1 | CSS Area | 21.375571 |
| 159 | 270 | Elephant & Castle | Northern, Bakerloo | 940GZZLUEAC | tube | Partially Accessible | No | London Underground | 2021-11-29 00:00:00+00:00 | Elephant & Castle station | POINT Z (531908.977 179141.89 0) | 0 | 1 | CSS Area | 21.375571 |
| 160 | 271 | Lambeth North | Bakerloo | 940GZZLULBN | bus, tube | Not Accessible | No | London Underground | 2021-11-29 00:00:00+00:00 | Lambeth North station | POINT Z (531133.594 179456.196 0) | 0 | 1 | CSS Area | 21.375571 |
| 172 | 283 | Westminster | District, Circle, Jubilee | 940GZZLUWSM | tube | Fully Accessible | Yes | London Underground | 2021-11-29 00:00:00+00:00 | Westminster station | POINT Z (530195.685 179668.229 0) | 0 | 1 | CSS Area | 21.375571 |
| 175 | 286 | Waterloo | Waterloo & City, Bakerloo, Northern, Jubilee | 940GZZLUWLO | tube | Partially Accessible | Yes | London Underground | 2021-11-29 00:00:00+00:00 | Waterloo station | POINT Z (530968.192 179961.919 0) | 0 | 1 | CSS Area | 21.375571 |
| 182 | 293 | Green Park | Piccadilly, Victoria, Jubilee | 940GZZLUGPK | bus, tube | Fully Accessible | Yes | London Underground | 2021-11-29 00:00:00+00:00 | Green Park station | POINT Z (529007.243 180294.838 0) | 0 | 1 | CSS Area | 21.375571 |
| 222 | 333 | Southwark | Jubilee | 940GZZLUSWK | bus, tube | Fully Accessible | Yes | London Underground | 2021-11-29 00:00:00+00:00 | Southwark station | POINT Z (531592.354 180073.994 0) | 0 | 1 | CSS Area | 21.375571 |
| 223 | 334 | London Bridge | Northern, Jubilee | 940GZZLULNB | tube | Fully Accessible | Yes | London Underground | 2021-11-29 00:00:00+00:00 | London Bridge station | POINT Z (532683.06 180188.856 0) | 0 | 1 | CSS Area | 21.375571 |
| 231 | 387 | Monument | District, Circle | 940GZZLUMMT | tube, bus | Partially Accessible - Interchange Only | No | London Underground | 2021-11-29 00:00:00+00:00 | Monument station | POINT Z (532911.932 180824.079 0) | 0 | 1 | CSS Area | 21.375571 |
| 242 | 398 | St. James's Park | District, Circle | 940GZZLUSJP | tube | Not Accessible | No | London Underground | 2021-11-29 00:00:00+00:00 | St. James's Park station | POINT Z (529646.618 179498.077 0) | 0 | 1 | CSS Area | 21.375571 |
| 264 | 479 | Borough | Northern | 940GZZLUBOR | bus, tube | Partially Accessible | No | London Underground | 2021-11-29 00:00:00+00:00 | Borough station | POINT Z (532439.975 179751.465 0) | 0 | 1 | CSS Area | 21.375571 |
| 265 | 480 | Old Street | Northern | 940GZZLUODS | tube | Not Accessible | No | London Underground | 2021-11-29 00:00:00+00:00 | Old Street station | POINT Z (532764.463 182418.815 0) | 0 | 1 | CSS Area | 21.375571 |
# We can plot the underground stations and the CCZ zone.
fig, ax = plt.subplots(figsize=(6, 6))
gdf_ccz.plot(ax=ax, edgecolor='black', color='#fff2f2', alpha=1, linewidth=0.6)
gdf_ccz_underground.plot(ax=ax, edgecolor='grey', color='royalblue', alpha=1, linewidth=0.4, markersize=15)
ax.set_axis_off()
Second, we can also perform a spatial join between the London cycle routes and the CCZ to find out which cycle routes are within the CCZ zone.
# Perform a spatial join between London cycle routes and CCZ zone.
gdf_ccz_cycle_routes = gpd.sjoin(gdf_cycle_routes, gdf_ccz, how='inner', predicate='within')
# We can observe that there are 13 cycle routes that are within the CCZ zone.
gdf_ccz_cycle_routes
| LABEL | PROGRAMME | ROUTE_NAME | ROUTE | MILESTONE | STATUS | PUBLIC_ | ROUTE_LENGTH_KM | PROGRAMME_UPDATED | OBJECTID_left | Shape__Length | geometry | index_right | OBJECTID_right | BOUNDARY | Shape_Area | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 4 | C41 | Cycleways | Euston to Holborn | Euston to Holborn | Complete | Complete | Yes | 1.181 | 2023-11-21 00:00:00+00:00 | 1995 | 1180.878708 | LINESTRING Z (530256.221 182467.95 0, 530287.0... | 0 | 1 | CSS Area | 21.375571 |
| 11 | C56 | Cycleways | C5 to Westmister Bridge | C5 to Westmister Bridge | Complete | Complete | Yes | 1.196 | 2023-11-21 00:00:00+00:00 | 2002 | 1196.244254 | MULTILINESTRING Z ((530953.012 179173.003 0, 5... | 0 | 1 | CSS Area | 21.375571 |
| 26 | C | Cycle Superhighways | Lancaster Gate to Barking | Horse Guards Road | Complete | Complete | Yes | 1.336 | 2023-11-21 00:00:00+00:00 | 2017 | 1336.495364 | LINESTRING Z (529902.012 179698.003 0, 529901.... | 0 | 1 | CSS Area | 21.375571 |
| 40 | C | Cycleways | Lambeth Roundabout to P.Square | Lambeth Roundabout to P.Square | (SG3) Concept Design | Feasibility | Yes | 0.598 | 2023-11-21 00:00:00+00:00 | 2031 | 598.403380 | LINESTRING Z (530153.625 179582.183 0, 530158.... | 0 | 1 | CSS Area | 21.375571 |
| 42 | C11 | Cycleways | Essex Road to Farringdon | The City to Farringdon | Complete | Complete | Yes | 1.243 | 2023-11-21 00:00:00+00:00 | 2033 | 1243.120260 | LINESTRING Z (532589.5 181938.471 0, 532573.01... | 0 | 1 | CSS Area | 21.375571 |
| 50 | C | Cycleways | C1 to Liverpool Street | C1 to Liverpool Street | Complete | Complete | Yes | 0.525 | 2023-11-21 00:00:00+00:00 | 2041 | 524.539812 | LINESTRING Z (532943.013 181895.004 0, 533034.... | 0 | 1 | CSS Area | 21.375571 |
| 73 | C | Cycleways | Lambeth Roundabout - North & South | Lambeth Roundabout - North & South | (SG4) Detailed Design | Feasibility | Yes | 0.519 | 2023-11-21 00:00:00+00:00 | 2064 | 519.098639 | LINESTRING Z (530529.705 178938.867 0, 530530.... | 0 | 1 | CSS Area | 21.375571 |
| 103 | C | Central London Grid | Fitzrovia to Soho | Fitzrovia to Soho | (SG4) Detailed Design | Feasibility | Yes | 0.942 | 2023-11-21 00:00:00+00:00 | 2094 | 942.260282 | LINESTRING Z (529476.013 181246.003 25.5, 5295... | 0 | 1 | CSS Area | 21.375571 |
| 110 | C | Central London Grid | Fitzrovia to Soho | Fitzrovia to Soho | (SG4) Detailed Design | Feasibility | Yes | 0.365 | 2023-11-21 00:00:00+00:00 | 2101 | 365.025555 | LINESTRING Z (529359.013 181642.003 28.4, 5293... | 0 | 1 | CSS Area | 21.375571 |
| 117 | C | Cycleways | C4 to C14 and C10 | C4 to C14 and C10 | (SG4) Detailed Design | Feasibility | Yes | 0.377 | 2023-11-21 00:00:00+00:00 | 2108 | 377.333957 | LINESTRING Z (533000.012 179343.004 0, 532947.... | 0 | 1 | CSS Area | 21.375571 |
| 118 | C | Cycleways | Waterloo Bridge | Waterloo Bridge | Complete | Complete | Yes | 0.491 | 2023-11-21 00:00:00+00:00 | 2109 | 490.560628 | LINESTRING Z (530689.012 180675.004 0, 530939.... | 0 | 1 | CSS Area | 21.375571 |
| 138 | C | Cycleways | Old Paradise Street | Old Paradise Street | Complete | Complete | Yes | 0.317 | 2023-11-21 00:00:00+00:00 | 2129 | 316.683268 | LINESTRING Z (530821.012 178867.003 0, 530813.... | 0 | 1 | CSS Area | 21.375571 |
| 161 | C10 | Cycleways | Blomsbury to Embankment | Blomsbury to Embankment | Complete | Complete | Yes | 1.421 | 2023-11-21 00:00:00+00:00 | 2152 | 1420.613731 | MULTILINESTRING Z ((530660.012 180658.004 0, 5... | 0 | 1 | CSS Area | 21.375571 |
# We can plot the cycle routes and the CCZ zone.
fig, ax = plt.subplots(figsize=(6, 6))
gdf_ccz.plot(ax=ax, edgecolor='black', color='#fff2f2', alpha=1, linewidth=0.6)
gdf_ccz_cycle_routes.plot(ax=ax, edgecolor='grey', color='royalblue', alpha=1, linewidth=2)
ax.set_axis_off()
Third, we can also perform a spatial join between the London cycle routes and the CCZ to find out which cycle routes are intersected with the CCZ zone.
# Perform a spatial join between London cycle routes and CCZ zone.
gdf_ccz_cycle_routes_intersect = gpd.sjoin(gdf_cycle_routes, gdf_ccz, how='inner', predicate='intersects')
# We can observe that there are 33 cycle routes that are intersected with the CCZ zone.
gdf_ccz_cycle_routes_intersect
| LABEL | PROGRAMME | ROUTE_NAME | ROUTE | MILESTONE | STATUS | PUBLIC_ | ROUTE_LENGTH_KM | PROGRAMME_UPDATED | OBJECTID_left | Shape__Length | geometry | index_right | OBJECTID_right | BOUNDARY | Shape_Area | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | C38 | Cycleways | Finsbury Park to Highbury Fields | Islington to Finsbury | (SG2) Option Selection | Feasibility | Yes | 0.566 | 2023-11-21 00:00:00+00:00 | 1991 | 565.899062 | LINESTRING Z (531183.013 182813.004 0, 531178.... | 0 | 1 | CSS Area | 21.375571 |
| 4 | C41 | Cycleways | Euston to Holborn | Euston to Holborn | Complete | Complete | Yes | 1.181 | 2023-11-21 00:00:00+00:00 | 1995 | 1180.878708 | LINESTRING Z (530256.221 182467.95 0, 530287.0... | 0 | 1 | CSS Area | 21.375571 |
| 11 | C56 | Cycleways | C5 to Westmister Bridge | C5 to Westmister Bridge | Complete | Complete | Yes | 1.196 | 2023-11-21 00:00:00+00:00 | 2002 | 1196.244254 | MULTILINESTRING Z ((530953.012 179173.003 0, 5... | 0 | 1 | CSS Area | 21.375571 |
| 15 | C6 | Cycleways | Elephant and Castle to Hampstead | Elephant and Castle to Kings Cross | Complete | Complete | Yes | 7.944 | 2023-11-21 00:00:00+00:00 | 2006 | 7944.208889 | MULTILINESTRING Z ((531907.151 179051.998 0, 5... | 0 | 1 | CSS Area | 21.375571 |
| 21 | CS7 | Cycleways | Merton to The City | Merton to The City | Complete | Complete | Yes | 12.525 | 2023-11-21 00:00:00+00:00 | 2012 | 12525.201532 | MULTILINESTRING Z ((526716.139 170267.543 0, 5... | 0 | 1 | CSS Area | 21.375571 |
| 22 | C3 | Cycleways | Lancaster Gate to Barking | Lancaster Gate to Barking | Complete | Complete | Yes | 22.425 | 2023-11-21 00:00:00+00:00 | 2013 | 22425.196420 | LINESTRING Z (545213.627 183267.215 0, 545181.... | 0 | 1 | CSS Area | 21.375571 |
| 26 | C | Cycle Superhighways | Lancaster Gate to Barking | Horse Guards Road | Complete | Complete | Yes | 1.336 | 2023-11-21 00:00:00+00:00 | 2017 | 1336.495364 | LINESTRING Z (529902.012 179698.003 0, 529901.... | 0 | 1 | CSS Area | 21.375571 |
| 27 | C8 | Cycleways | Wandsworth to Lambeth Bridge | Wandsworth to Battersea Park | Complete | Complete | Yes | 3.288 | 2023-11-21 00:00:00+00:00 | 2018 | 3284.253577 | MULTILINESTRING Z ((530244.703 178963.655 0, 5... | 0 | 1 | CSS Area | 21.375571 |
| 35 | C5 | Cycleways | Waterloo to Clapham | Waterloo to Clapham | Complete | Complete | Yes | 2.076 | 2023-11-21 00:00:00+00:00 | 2026 | 2076.093601 | LINESTRING Z (530517.627 178020.692 0, 530519.... | 0 | 1 | CSS Area | 21.375571 |
| 40 | C | Cycleways | Lambeth Roundabout to P.Square | Lambeth Roundabout to P.Square | (SG3) Concept Design | Feasibility | Yes | 0.598 | 2023-11-21 00:00:00+00:00 | 2031 | 598.403380 | LINESTRING Z (530153.625 179582.183 0, 530158.... | 0 | 1 | CSS Area | 21.375571 |
| 41 | C | Cycleways | Marylbone Road to Oxford Street | Marylbone Road to Oxford Street | (SG3) Concept Design | Feasibility | Yes | 0.905 | 2023-11-21 00:00:00+00:00 | 2032 | 905.142174 | MULTILINESTRING Z ((528932.381 181516.591 0, 5... | 0 | 1 | CSS Area | 21.375571 |
| 42 | C11 | Cycleways | Essex Road to Farringdon | The City to Farringdon | Complete | Complete | Yes | 1.243 | 2023-11-21 00:00:00+00:00 | 2033 | 1243.120260 | LINESTRING Z (532589.5 181938.471 0, 532573.01... | 0 | 1 | CSS Area | 21.375571 |
| 49 | C | Cycleways | Waterloo to Clapham | C5 to C14 - The Cut_Union Street | Complete | Complete | Yes | 2.224 | 2023-11-21 00:00:00+00:00 | 2040 | 2224.308731 | MULTILINESTRING Z ((531313.012 179849.003 0, 5... | 0 | 1 | CSS Area | 21.375571 |
| 50 | C | Cycleways | C1 to Liverpool Street | C1 to Liverpool Street | Complete | Complete | Yes | 0.525 | 2023-11-21 00:00:00+00:00 | 2041 | 524.539812 | LINESTRING Z (532943.013 181895.004 0, 533034.... | 0 | 1 | CSS Area | 21.375571 |
| 54 | C52 | Quietways | Covent Garden to Euston | Covent Garden to Euston | Complete | Complete | Yes | 2.561 | 2023-11-21 00:00:00+00:00 | 2045 | 2560.879009 | MULTILINESTRING Z ((530689.012 180675.004 0, 5... | 0 | 1 | CSS Area | 21.375571 |
| 55 | C4 | Cycleways | London Bridge to Rotherhithe Roundabout | London Bridge to Rotherhithe Roundabout | Complete | Complete | Yes | 2.998 | 2023-11-21 00:00:00+00:00 | 2046 | 2997.526255 | MULTILINESTRING Z ((533882.927 179664.769 0, 5... | 0 | 1 | CSS Area | 21.375571 |
| 72 | C | Cycleways | C2 to C3 via Mansell Street | Mansell Street | Complete | Complete | Yes | 0.499 | 2023-11-21 00:00:00+00:00 | 2063 | 498.680116 | MULTILINESTRING Z ((533824.899 180911.007 0, 5... | 0 | 1 | CSS Area | 21.375571 |
| 73 | C | Cycleways | Lambeth Roundabout - North & South | Lambeth Roundabout - North & South | (SG4) Detailed Design | Feasibility | Yes | 0.519 | 2023-11-21 00:00:00+00:00 | 2064 | 519.098639 | LINESTRING Z (530529.705 178938.867 0, 530530.... | 0 | 1 | CSS Area | 21.375571 |
| 77 | C1 | Cycleways | Freezey Water to The City | Freezey Water to The City | Complete | Complete | Yes | 20.165 | 2023-11-21 00:00:00+00:00 | 2068 | 20164.517337 | MULTILINESTRING Z ((533372.013 185167.475 0, 5... | 0 | 1 | CSS Area | 21.375571 |
| 81 | C2 | Cycleways | Aldgate to Stratford | Aldgate to Stratford | Complete | Complete | Yes | 6.370 | 2023-11-21 00:00:00+00:00 | 2072 | 6369.852153 | LINESTRING Z (533742.047 181260.481 0, 533770.... | 0 | 1 | CSS Area | 21.375571 |
| 82 | C17 | Cycleways | Elephant and Castle to Dulwich | Elephant and Castle to Camberwell | Complete | Complete | Yes | 4.002 | 2023-11-21 00:00:00+00:00 | 2073 | 4001.525575 | MULTILINESTRING Z ((533053.013 176407.005 0, 5... | 0 | 1 | CSS Area | 21.375571 |
| 83 | C14 | Cycleways | Blackfriars to Rotherhithe | Blackfriars to Rotherhithe | Complete | Complete | Yes | 6.995 | 2023-11-21 00:00:00+00:00 | 2074 | 6994.926446 | LINESTRING Z (536851.344 178582.957 0, 536806.... | 0 | 1 | CSS Area | 21.375571 |
| 103 | C | Central London Grid | Fitzrovia to Soho | Fitzrovia to Soho | (SG4) Detailed Design | Feasibility | Yes | 0.942 | 2023-11-21 00:00:00+00:00 | 2094 | 942.260282 | LINESTRING Z (529476.013 181246.003 25.5, 5295... | 0 | 1 | CSS Area | 21.375571 |
| 109 | C51 | Central London Grid | Marylebone to Kilburn | Marylebone to Kilburn | (SG4) Detailed Design | Feasibility | Yes | 3.296 | 2023-11-21 00:00:00+00:00 | 2100 | 3266.659774 | MULTILINESTRING Z ((525973.014 183317.004 0, 5... | 0 | 1 | CSS Area | 21.375571 |
| 110 | C | Central London Grid | Fitzrovia to Soho | Fitzrovia to Soho | (SG4) Detailed Design | Feasibility | Yes | 0.365 | 2023-11-21 00:00:00+00:00 | 2101 | 365.025555 | LINESTRING Z (529359.013 181642.003 28.4, 5293... | 0 | 1 | CSS Area | 21.375571 |
| 113 | C27 | Quietways | East Acton to Walthamstow | East Acton to Walthamstow | Complete | Complete | Yes | 8.679 | 2023-11-21 00:00:00+00:00 | 2104 | 8678.992253 | MULTILINESTRING Z ((530915.411 182414.783 0, 5... | 0 | 1 | CSS Area | 21.375571 |
| 114 | C27 | Cycleways | East Acton to Walthamstow | East Acton to Walthamstow | Complete | Complete | Yes | 16.363 | 2023-11-21 00:00:00+00:00 | 2105 | 16363.310394 | MULTILINESTRING Z ((525556.013 180543.005 0, 5... | 0 | 1 | CSS Area | 21.375571 |
| 117 | C | Cycleways | C4 to C14 and C10 | C4 to C14 and C10 | (SG4) Detailed Design | Feasibility | Yes | 0.377 | 2023-11-21 00:00:00+00:00 | 2108 | 377.333957 | LINESTRING Z (533000.012 179343.004 0, 532947.... | 0 | 1 | CSS Area | 21.375571 |
| 118 | C | Cycleways | Waterloo Bridge | Waterloo Bridge | Complete | Complete | Yes | 0.491 | 2023-11-21 00:00:00+00:00 | 2109 | 490.560628 | LINESTRING Z (530689.012 180675.004 0, 530939.... | 0 | 1 | CSS Area | 21.375571 |
| 120 | C | Cycleways | Oval to C5 | Oval to C5 | Complete | Complete | Yes | 1.032 | 2023-11-21 00:00:00+00:00 | 2111 | 1032.298014 | LINESTRING Z (530700.012 178648.003 0, 530744.... | 0 | 1 | CSS Area | 21.375571 |
| 126 | C10 | Cycleways | Waterloo to Greenwich | Waterloo to Greenwich | Complete | Complete | Yes | 10.543 | 2023-11-21 00:00:00+00:00 | 2117 | 10542.684407 | MULTILINESTRING Z ((534881.008 178422 0, 53489... | 0 | 1 | CSS Area | 21.375571 |
| 138 | C | Cycleways | Old Paradise Street | Old Paradise Street | Complete | Complete | Yes | 0.317 | 2023-11-21 00:00:00+00:00 | 2129 | 316.683268 | LINESTRING Z (530821.012 178867.003 0, 530813.... | 0 | 1 | CSS Area | 21.375571 |
| 139 | C11 | Cycleways | Essex Road to Farringdon | Essex Road to The City | Complete | Complete | Yes | 2.123 | 2023-11-21 00:00:00+00:00 | 2130 | 2123.492454 | LINESTRING Z (531859.147 183765.678 0, 532107.... | 0 | 1 | CSS Area | 21.375571 |
| 145 | C13 | Cycleways | Old Street to London Fields | Old Street to London Fields | Complete | Complete | Yes | 3.184 | 2023-11-21 00:00:00+00:00 | 2136 | 3184.007679 | MULTILINESTRING Z ((532565.261 182352.57 0, 53... | 0 | 1 | CSS Area | 21.375571 |
| 161 | C10 | Cycleways | Blomsbury to Embankment | Blomsbury to Embankment | Complete | Complete | Yes | 1.421 | 2023-11-21 00:00:00+00:00 | 2152 | 1420.613731 | MULTILINESTRING Z ((530660.012 180658.004 0, 5... | 0 | 1 | CSS Area | 21.375571 |
We can observe that some cycle routes are not within the CCZ zone but they are intersected with the CCZ zone. This is because some cycle routes are represented by multilinestrings (even they are not connected).
# We can plot the cycle routes and the CCZ zone.
fig, ax = plt.subplots(figsize=(6, 6))
gdf_ccz.plot(ax=ax, edgecolor='black', color='#fff2f2', alpha=1, linewidth=0.6)
gdf_ccz_cycle_routes_intersect.plot(ax=ax, edgecolor='grey', color='royalblue', alpha=1, linewidth=1)
ax.set_axis_off()
Now, we only select the linestring from the multilinestring in cycle route then using spatial joins (intersect) with the CCZ.
# Select the linestring from the multilinestring in the cycle route.
gdf_cycle_routes_s = gdf_cycle_routes[gdf_cycle_routes['geometry'].type == 'LineString']
gdf_cycle_routes_s
| LABEL | PROGRAMME | ROUTE_NAME | ROUTE | MILESTONE | STATUS | PUBLIC_ | ROUTE_LENGTH_KM | PROGRAMME_UPDATED | OBJECTID | Shape__Length | geometry | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | C38 | Cycleways | Finsbury Park to Highbury Fields | Islington to Finsbury | (SG2) Option Selection | Feasibility | Yes | 0.566 | 2023-11-21 00:00:00+00:00 | 1991 | 565.899062 | LINESTRING Z (531183.013 182813.004 0, 531178.... |
| 1 | C48 | Cycleways | Brixton to Clapham High Street | Brixton to Clapham High Street | Complete | Complete | Yes | 1.315 | 2023-11-21 00:00:00+00:00 | 1992 | 1315.182747 | LINESTRING Z (531059.242 175496.769 0, 531068.... |
| 4 | C41 | Cycleways | Euston to Holborn | Euston to Holborn | Complete | Complete | Yes | 1.181 | 2023-11-21 00:00:00+00:00 | 1995 | 1180.878708 | LINESTRING Z (530256.221 182467.95 0, 530287.0... |
| 5 | C55 | Cycleways | Lancaster Gate to Hyde Park Corner | Lancaster Gate to Hyde Park Corner | Complete | Complete | Yes | 0.723 | 2023-11-21 00:00:00+00:00 | 1996 | 723.280344 | LINESTRING Z (526926.013 180815.005 0, 526936.... |
| 7 | C49 | Cycleways | Acton to Chiswick | Acton to Chiswick | Complete | Complete | Yes | 4.210 | 2023-11-21 00:00:00+00:00 | 1998 | 4209.703771 | LINESTRING Z (521096.17 178513.522 0, 521106.7... |
| ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| 160 | C50 | Cycleways | Camden Town to Finsbury Park | Camden Town to York Way | Complete | Complete | Yes | 1.133 | 2023-11-21 00:00:00+00:00 | 2151 | 1132.913927 | LINESTRING Z (529230.013 184130.004 28.3, 5292... |
| 162 | C | Cycleways | Elephant and Castle to Hampstead | Castlehaven Grafton Road | Complete | Complete | Yes | 1.833 | 2023-11-21 00:00:00+00:00 | 2153 | 1832.819766 | LINESTRING Z (527666.121 185680.674 0, 527717.... |
| 163 | C40 | Cycleways | Brentford to Twickenham | Brentford to Twickenham | Complete | Complete | Yes | 4.291 | 2023-11-21 00:00:00+00:00 | 2154 | 4291.196598 | LINESTRING Z (516031.691 173764.752 0, 516046.... |
| 164 | C4 | Cycleways | London Bridge to Rotherhithe Roundabout | Rotherhithe Roundabout to Lewisham | (SG5) Delivery | In Progress | Yes | 1.335 | 2023-11-21 00:00:00+00:00 | 2155 | 1335.083915 | LINESTRING Z (536021.013 178603.004 0, 535965.... |
| 165 | C39 | Cycleways | Kensington High St to Shepherds Bush | Kensington High St to Shepherds Bush | Complete | Complete | Yes | 1.151 | 2023-11-21 00:00:00+00:00 | 2156 | 1151.249368 | LINESTRING Z (524567.603 179008.18 0, 524508.3... |
123 rows × 12 columns
# spatial join between the linestring and CCZ zone.
gdf_ccz_cycle_routes_intersect_linestring = gpd.sjoin(gdf_cycle_routes_s, gdf_ccz, how='inner', predicate='intersects')
# We can observe that there are 17 cycle routes that are intersected with the CCZ zone.
gdf_ccz_cycle_routes_intersect_linestring
| LABEL | PROGRAMME | ROUTE_NAME | ROUTE | MILESTONE | STATUS | PUBLIC_ | ROUTE_LENGTH_KM | PROGRAMME_UPDATED | OBJECTID_left | Shape__Length | geometry | index_right | OBJECTID_right | BOUNDARY | Shape_Area | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | C38 | Cycleways | Finsbury Park to Highbury Fields | Islington to Finsbury | (SG2) Option Selection | Feasibility | Yes | 0.566 | 2023-11-21 00:00:00+00:00 | 1991 | 565.899062 | LINESTRING Z (531183.013 182813.004 0, 531178.... | 0 | 1 | CSS Area | 21.375571 |
| 4 | C41 | Cycleways | Euston to Holborn | Euston to Holborn | Complete | Complete | Yes | 1.181 | 2023-11-21 00:00:00+00:00 | 1995 | 1180.878708 | LINESTRING Z (530256.221 182467.95 0, 530287.0... | 0 | 1 | CSS Area | 21.375571 |
| 22 | C3 | Cycleways | Lancaster Gate to Barking | Lancaster Gate to Barking | Complete | Complete | Yes | 22.425 | 2023-11-21 00:00:00+00:00 | 2013 | 22425.196420 | LINESTRING Z (545213.627 183267.215 0, 545181.... | 0 | 1 | CSS Area | 21.375571 |
| 26 | C | Cycle Superhighways | Lancaster Gate to Barking | Horse Guards Road | Complete | Complete | Yes | 1.336 | 2023-11-21 00:00:00+00:00 | 2017 | 1336.495364 | LINESTRING Z (529902.012 179698.003 0, 529901.... | 0 | 1 | CSS Area | 21.375571 |
| 35 | C5 | Cycleways | Waterloo to Clapham | Waterloo to Clapham | Complete | Complete | Yes | 2.076 | 2023-11-21 00:00:00+00:00 | 2026 | 2076.093601 | LINESTRING Z (530517.627 178020.692 0, 530519.... | 0 | 1 | CSS Area | 21.375571 |
| 40 | C | Cycleways | Lambeth Roundabout to P.Square | Lambeth Roundabout to P.Square | (SG3) Concept Design | Feasibility | Yes | 0.598 | 2023-11-21 00:00:00+00:00 | 2031 | 598.403380 | LINESTRING Z (530153.625 179582.183 0, 530158.... | 0 | 1 | CSS Area | 21.375571 |
| 42 | C11 | Cycleways | Essex Road to Farringdon | The City to Farringdon | Complete | Complete | Yes | 1.243 | 2023-11-21 00:00:00+00:00 | 2033 | 1243.120260 | LINESTRING Z (532589.5 181938.471 0, 532573.01... | 0 | 1 | CSS Area | 21.375571 |
| 50 | C | Cycleways | C1 to Liverpool Street | C1 to Liverpool Street | Complete | Complete | Yes | 0.525 | 2023-11-21 00:00:00+00:00 | 2041 | 524.539812 | LINESTRING Z (532943.013 181895.004 0, 533034.... | 0 | 1 | CSS Area | 21.375571 |
| 73 | C | Cycleways | Lambeth Roundabout - North & South | Lambeth Roundabout - North & South | (SG4) Detailed Design | Feasibility | Yes | 0.519 | 2023-11-21 00:00:00+00:00 | 2064 | 519.098639 | LINESTRING Z (530529.705 178938.867 0, 530530.... | 0 | 1 | CSS Area | 21.375571 |
| 81 | C2 | Cycleways | Aldgate to Stratford | Aldgate to Stratford | Complete | Complete | Yes | 6.370 | 2023-11-21 00:00:00+00:00 | 2072 | 6369.852153 | LINESTRING Z (533742.047 181260.481 0, 533770.... | 0 | 1 | CSS Area | 21.375571 |
| 83 | C14 | Cycleways | Blackfriars to Rotherhithe | Blackfriars to Rotherhithe | Complete | Complete | Yes | 6.995 | 2023-11-21 00:00:00+00:00 | 2074 | 6994.926446 | LINESTRING Z (536851.344 178582.957 0, 536806.... | 0 | 1 | CSS Area | 21.375571 |
| 103 | C | Central London Grid | Fitzrovia to Soho | Fitzrovia to Soho | (SG4) Detailed Design | Feasibility | Yes | 0.942 | 2023-11-21 00:00:00+00:00 | 2094 | 942.260282 | LINESTRING Z (529476.013 181246.003 25.5, 5295... | 0 | 1 | CSS Area | 21.375571 |
| 110 | C | Central London Grid | Fitzrovia to Soho | Fitzrovia to Soho | (SG4) Detailed Design | Feasibility | Yes | 0.365 | 2023-11-21 00:00:00+00:00 | 2101 | 365.025555 | LINESTRING Z (529359.013 181642.003 28.4, 5293... | 0 | 1 | CSS Area | 21.375571 |
| 117 | C | Cycleways | C4 to C14 and C10 | C4 to C14 and C10 | (SG4) Detailed Design | Feasibility | Yes | 0.377 | 2023-11-21 00:00:00+00:00 | 2108 | 377.333957 | LINESTRING Z (533000.012 179343.004 0, 532947.... | 0 | 1 | CSS Area | 21.375571 |
| 118 | C | Cycleways | Waterloo Bridge | Waterloo Bridge | Complete | Complete | Yes | 0.491 | 2023-11-21 00:00:00+00:00 | 2109 | 490.560628 | LINESTRING Z (530689.012 180675.004 0, 530939.... | 0 | 1 | CSS Area | 21.375571 |
| 120 | C | Cycleways | Oval to C5 | Oval to C5 | Complete | Complete | Yes | 1.032 | 2023-11-21 00:00:00+00:00 | 2111 | 1032.298014 | LINESTRING Z (530700.012 178648.003 0, 530744.... | 0 | 1 | CSS Area | 21.375571 |
| 138 | C | Cycleways | Old Paradise Street | Old Paradise Street | Complete | Complete | Yes | 0.317 | 2023-11-21 00:00:00+00:00 | 2129 | 316.683268 | LINESTRING Z (530821.012 178867.003 0, 530813.... | 0 | 1 | CSS Area | 21.375571 |
| 139 | C11 | Cycleways | Essex Road to Farringdon | Essex Road to The City | Complete | Complete | Yes | 2.123 | 2023-11-21 00:00:00+00:00 | 2130 | 2123.492454 | LINESTRING Z (531859.147 183765.678 0, 532107.... | 0 | 1 | CSS Area | 21.375571 |
# We can plot the cycle routes and the CCZ zone.
fig, ax = plt.subplots(figsize=(10, 8))
gdf_ccz.plot(ax=ax, edgecolor='black', color='#fff2f2', alpha=1, linewidth=0.6)
gdf_ccz_cycle_routes_intersect_linestring.plot(ax=ax, edgecolor='grey', color='royalblue', alpha=1, linewidth=2)
ax.set_axis_off()
Then, we can also perform a spatial join between the London cycle routes (single linestrings) and the CCZ to find out which cycle routes are crosses the CCZ.
# Perform a spatial join between London cycle routes and CCZ.
gdf_ccz_cycle_routes_cross = gpd.sjoin(gdf_cycle_routes_s, gdf_ccz, how='inner', predicate='crosses')
# We can observe that there are 6 cycle routes that are crossed with the CCZ.
gdf_ccz_cycle_routes_cross
| LABEL | PROGRAMME | ROUTE_NAME | ROUTE | MILESTONE | STATUS | PUBLIC_ | ROUTE_LENGTH_KM | PROGRAMME_UPDATED | OBJECTID_left | Shape__Length | geometry | index_right | OBJECTID_right | BOUNDARY | Shape_Area | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | C38 | Cycleways | Finsbury Park to Highbury Fields | Islington to Finsbury | (SG2) Option Selection | Feasibility | Yes | 0.566 | 2023-11-21 00:00:00+00:00 | 1991 | 565.899062 | LINESTRING Z (531183.013 182813.004 0, 531178.... | 0 | 1 | CSS Area | 21.375571 |
| 22 | C3 | Cycleways | Lancaster Gate to Barking | Lancaster Gate to Barking | Complete | Complete | Yes | 22.425 | 2023-11-21 00:00:00+00:00 | 2013 | 22425.196420 | LINESTRING Z (545213.627 183267.215 0, 545181.... | 0 | 1 | CSS Area | 21.375571 |
| 35 | C5 | Cycleways | Waterloo to Clapham | Waterloo to Clapham | Complete | Complete | Yes | 2.076 | 2023-11-21 00:00:00+00:00 | 2026 | 2076.093601 | LINESTRING Z (530517.627 178020.692 0, 530519.... | 0 | 1 | CSS Area | 21.375571 |
| 81 | C2 | Cycleways | Aldgate to Stratford | Aldgate to Stratford | Complete | Complete | Yes | 6.370 | 2023-11-21 00:00:00+00:00 | 2072 | 6369.852153 | LINESTRING Z (533742.047 181260.481 0, 533770.... | 0 | 1 | CSS Area | 21.375571 |
| 83 | C14 | Cycleways | Blackfriars to Rotherhithe | Blackfriars to Rotherhithe | Complete | Complete | Yes | 6.995 | 2023-11-21 00:00:00+00:00 | 2074 | 6994.926446 | LINESTRING Z (536851.344 178582.957 0, 536806.... | 0 | 1 | CSS Area | 21.375571 |
| 120 | C | Cycleways | Oval to C5 | Oval to C5 | Complete | Complete | Yes | 1.032 | 2023-11-21 00:00:00+00:00 | 2111 | 1032.298014 | LINESTRING Z (530700.012 178648.003 0, 530744.... | 0 | 1 | CSS Area | 21.375571 |
| 139 | C11 | Cycleways | Essex Road to Farringdon | Essex Road to The City | Complete | Complete | Yes | 2.123 | 2023-11-21 00:00:00+00:00 | 2130 | 2123.492454 | LINESTRING Z (531859.147 183765.678 0, 532107.... | 0 | 1 | CSS Area | 21.375571 |
# We can plot the cycle routes and the CCZ zone.
fig, ax = plt.subplots(figsize=(10, 8))
gdf_ccz.plot(ax=ax, edgecolor='black', color='#fff2f2', alpha=1, linewidth=0.6)
gdf_ccz_cycle_routes_cross.plot(ax=ax, edgecolor='grey', color='royalblue', alpha=1, linewidth=2)
ax.set_axis_off()
Quiz#
Q1. Using spatial join to select the London Underground stations that are within the City of London (one LA of London), and plot the stations and City of London map.
Q2. Using spatial join to find the numbers of London Underground stations that are within each LA in London, output a table to list the LA names and station numbers.
Q3. To find the cycle routes (only consider the cycle routes geometry are LineStrings, not mutiLineString) are within the Camden, and plot the cycle routes and camden map.
Q4. Use the cycle route ([‘OBJECTID’] == 2096) we used in the buffer example, then find the underground stations that are within the 500m buffer area and 500m-1000m buffer area of this cycle route, and plot the cycle route, the buffer areas, and the related underground stations.
Q5. Use the ‘central’ line underground stations to build the 500m buffer areas, then find the cycle routes (only consider the cycle routes geometry is LineStrings, not mutiLineString) that are crossing these buffer areas of these underground stations, and plot the cycle routes, the buffer areas, and the related underground stations.
Q1 solution:
# Select City of London from London LAs
gdf_city_london = gdf_uk_london[gdf_uk_london['LAD24NM'] == 'City of London']
# Spatial join to find stations within City of London
gdf_city_underground = gpd.sjoin(gdf_underground, gdf_city_london, how='inner', predicate='within')
# Plot City of London and its underground stations
fig, ax = plt.subplots(figsize=(6, 6))
gdf_city_london.plot(ax=ax, edgecolor='black', color='skyblue', alpha=0.4)
gdf_city_underground.plot(ax=ax, edgecolor='grey', color='red', alpha=1, markersize=50)
ax.set_axis_off()
#
Q2 solution:
# Spatial join to find stations within each LA in London
gdf_la_underground = gpd.sjoin(gdf_underground, gdf_uk_london, how='inner', predicate='within')
# We can observe that there are 257 underground stations within London LA boundaries.
gdf_la_underground
| OBJECTID | NAME | LINES | ATCOCODE | MODES | ACCESSIBILITY | NIGHT_TUBE | NETWORK | DATASET_LAST_UPDATED | FULL_NAME | ... | FID | LAD24CD | LAD24NM | LAD24NMW | BNG_E | BNG_N | LONG | LAT | GlobalID | intersected | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | 111 | St. Paul's | Central | 940GZZLUSPU | bus, tube | Not Accessible | Yes | London Underground | 2021-11-29 00:00:00+00:00 | St. Paul's station | ... | 264 | E09000001 | City of London | 532382 | 181358 | -0.093520 | 51.51564 | 741710fd-03e1-4b41-8645-7ebcfc5961ac | intersected | |
| 1 | 112 | Mile End | District, Hammersmith & City, Central | 940GZZLUMED | bus, tube | Partially Accessible - Interchange Only | Yes | London Underground | 2021-11-29 00:00:00+00:00 | Mile End station | ... | 293 | E09000030 | Tower Hamlets | 536340 | 181452 | -0.036480 | 51.51555 | 54f82e61-dc15-42cb-b777-681b4326f855 | intersected | |
| 2 | 113 | Bethnal Green | Central | 940GZZLUBLG | bus, tube | Not Accessible | Yes | London Underground | 2021-11-29 00:00:00+00:00 | Bethnal Green station | ... | 293 | E09000030 | Tower Hamlets | 536340 | 181452 | -0.036480 | 51.51555 | 54f82e61-dc15-42cb-b777-681b4326f855 | intersected | |
| 3 | 114 | Leyton | Central | 940GZZLULYN | bus, tube | Not Accessible | Yes | London Underground | 2021-11-29 00:00:00+00:00 | Leyton station | ... | 294 | E09000031 | Waltham Forest | 537328 | 190278 | -0.018800 | 51.59462 | 97cd624f-2c02-4f12-a78e-7aedc777673f | not_intersected | |
| 4 | 115 | Snaresbrook | Central | 940GZZLUSNB | bus, tube | Not Accessible | Yes | London Underground | 2021-11-29 00:00:00+00:00 | Snaresbrook station | ... | 289 | E09000026 | Redbridge | 543512 | 189477 | 0.070085 | 51.58588 | 947652cf-8d04-498f-aeac-8cb34f1052d8 | not_intersected | |
| ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| 267 | 482 | Hendon Central | Northern | 940GZZLUHCL | tube, bus | Fully Accessible | Yes | London Underground | 2021-11-29 00:00:00+00:00 | Hendon Central station | ... | 266 | E09000003 | Barnet | 523473 | 191752 | -0.218200 | 51.61107 | 9c7bda3b-2831-4799-857a-c83a49d16e4e | not_intersected | |
| 268 | 483 | Seven Sisters | Victoria | 940GZZLUSVS | tube | Not Accessible | Yes | London Underground | 2021-11-29 00:00:00+00:00 | Seven Sisters station | ... | 277 | E09000014 | Haringey | 531260 | 189349 | -0.106700 | 51.58772 | a4407a53-4227-42ea-be81-5933bf73fc98 | not_intersected | |
| 270 | 485 | Kenton | Bakerloo | 940GZZLUKEN | tube | Not Accessible | No | London Underground | 2021-11-29 00:00:00+00:00 | Kenton station | ... | 268 | E09000005 | Brent | 519615 | 186465 | -0.275690 | 51.56439 | 3b5f8a90-cb62-4570-984f-fbf322e910bc | not_intersected | |
| 271 | 486 | Woodside Park | Northern | 940GZZLUWOP | tube, bus | Fully Accessible | No | London Underground | 2021-11-29 00:00:00+00:00 | Woodside Park station | ... | 266 | E09000003 | Barnet | 523473 | 191752 | -0.218200 | 51.61107 | 9c7bda3b-2831-4799-857a-c83a49d16e4e | not_intersected | |
| 272 | 487 | Preston Road | Metropolitan | 940GZZLUPRD | tube, bus | Not Accessible | No | London Underground | 2021-11-29 00:00:00+00:00 | Preston Road station | ... | 268 | E09000005 | Brent | 519615 | 186465 | -0.275690 | 51.56439 | 3b5f8a90-cb62-4570-984f-fbf322e910bc | not_intersected |
257 rows × 22 columns
# We use groupby to count the number of stations in each LA, 27 LAs obtain the underground stations.
stations_per_la = gdf_la_underground.groupby('LAD24NM').size().reset_index(name='station_count')
stations_per_la = stations_per_la.sort_values('station_count', ascending=False)
stations_per_la
| LAD24NM | station_count | |
|---|---|---|
| 26 | Westminster | 34 |
| 2 | Brent | 20 |
| 3 | Camden | 17 |
| 9 | Hammersmith and Fulham | 16 |
| 13 | Hillingdon | 15 |
| 5 | Ealing | 14 |
| 1 | Barnet | 13 |
| 4 | City of London | 12 |
| 11 | Harrow | 10 |
| 20 | Redbridge | 10 |
| 17 | Lambeth | 10 |
| 16 | Kensington and Chelsea | 10 |
| 15 | Islington | 9 |
| 14 | Hounslow | 8 |
| 23 | Tower Hamlets | 8 |
| 22 | Southwark | 7 |
| 10 | Haringey | 6 |
| 19 | Newham | 6 |
| 25 | Wandsworth | 6 |
| 18 | Merton | 5 |
| 0 | Barking and Dagenham | 5 |
| 12 | Havering | 4 |
| 6 | Enfield | 4 |
| 24 | Waltham Forest | 4 |
| 21 | Richmond upon Thames | 2 |
| 8 | Hackney | 1 |
| 7 | Greenwich | 1 |
Q3 solution:
# Select cycle routes with linestring in geometry (we have used the gdf_cycle_routes_s in the spatial join before).
gdf_cycle_routes_s
| LABEL | PROGRAMME | ROUTE_NAME | ROUTE | MILESTONE | STATUS | PUBLIC_ | ROUTE_LENGTH_KM | PROGRAMME_UPDATED | OBJECTID | Shape__Length | geometry | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | C38 | Cycleways | Finsbury Park to Highbury Fields | Islington to Finsbury | (SG2) Option Selection | Feasibility | Yes | 0.566 | 2023-11-21 00:00:00+00:00 | 1991 | 565.899062 | LINESTRING Z (531183.013 182813.004 0, 531178.... |
| 1 | C48 | Cycleways | Brixton to Clapham High Street | Brixton to Clapham High Street | Complete | Complete | Yes | 1.315 | 2023-11-21 00:00:00+00:00 | 1992 | 1315.182747 | LINESTRING Z (531059.242 175496.769 0, 531068.... |
| 4 | C41 | Cycleways | Euston to Holborn | Euston to Holborn | Complete | Complete | Yes | 1.181 | 2023-11-21 00:00:00+00:00 | 1995 | 1180.878708 | LINESTRING Z (530256.221 182467.95 0, 530287.0... |
| 5 | C55 | Cycleways | Lancaster Gate to Hyde Park Corner | Lancaster Gate to Hyde Park Corner | Complete | Complete | Yes | 0.723 | 2023-11-21 00:00:00+00:00 | 1996 | 723.280344 | LINESTRING Z (526926.013 180815.005 0, 526936.... |
| 7 | C49 | Cycleways | Acton to Chiswick | Acton to Chiswick | Complete | Complete | Yes | 4.210 | 2023-11-21 00:00:00+00:00 | 1998 | 4209.703771 | LINESTRING Z (521096.17 178513.522 0, 521106.7... |
| ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| 160 | C50 | Cycleways | Camden Town to Finsbury Park | Camden Town to York Way | Complete | Complete | Yes | 1.133 | 2023-11-21 00:00:00+00:00 | 2151 | 1132.913927 | LINESTRING Z (529230.013 184130.004 28.3, 5292... |
| 162 | C | Cycleways | Elephant and Castle to Hampstead | Castlehaven Grafton Road | Complete | Complete | Yes | 1.833 | 2023-11-21 00:00:00+00:00 | 2153 | 1832.819766 | LINESTRING Z (527666.121 185680.674 0, 527717.... |
| 163 | C40 | Cycleways | Brentford to Twickenham | Brentford to Twickenham | Complete | Complete | Yes | 4.291 | 2023-11-21 00:00:00+00:00 | 2154 | 4291.196598 | LINESTRING Z (516031.691 173764.752 0, 516046.... |
| 164 | C4 | Cycleways | London Bridge to Rotherhithe Roundabout | Rotherhithe Roundabout to Lewisham | (SG5) Delivery | In Progress | Yes | 1.335 | 2023-11-21 00:00:00+00:00 | 2155 | 1335.083915 | LINESTRING Z (536021.013 178603.004 0, 535965.... |
| 165 | C39 | Cycleways | Kensington High St to Shepherds Bush | Kensington High St to Shepherds Bush | Complete | Complete | Yes | 1.151 | 2023-11-21 00:00:00+00:00 | 2156 | 1151.249368 | LINESTRING Z (524567.603 179008.18 0, 524508.3... |
123 rows × 12 columns
# the types of geometry in gdf_cycle_routes_s
gdf_cycle_routes_s.geometry.type.unique()
array(['LineString'], dtype=object)
# we have used the gdf_camden
gdf_camden
| FID | LAD24CD | LAD24NM | LAD24NMW | BNG_E | BNG_N | LONG | LAT | GlobalID | geometry | |
|---|---|---|---|---|---|---|---|---|---|---|
| 269 | 270 | E09000007 | Camden | 527491 | 184283 | -0.16291 | 51.54305 | 88f3f650-53ac-434d-883e-6235b48d14c4 | POLYGON ((529150.075 185862.023, 529701.341 18... |
# Spatial join to find cycle routes within Camden
gdf_camden_cycle_routes = gpd.sjoin(gdf_cycle_routes_s, gdf_camden, how='inner', predicate='within')
# We can observe that there are 13 cycle routes within Camden.
gdf_camden_cycle_routes
| LABEL | PROGRAMME | ROUTE_NAME | ROUTE | MILESTONE | STATUS | PUBLIC_ | ROUTE_LENGTH_KM | PROGRAMME_UPDATED | OBJECTID | ... | index_right | FID | LAD24CD | LAD24NM | LAD24NMW | BNG_E | BNG_N | LONG | LAT | GlobalID | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 4 | C41 | Cycleways | Euston to Holborn | Euston to Holborn | Complete | Complete | Yes | 1.181 | 2023-11-21 00:00:00+00:00 | 1995 | ... | 269 | 270 | E09000007 | Camden | 527491 | 184283 | -0.16291 | 51.54305 | 88f3f650-53ac-434d-883e-6235b48d14c4 | |
| 9 | C6 | Cycleways | Elephant and Castle to Hampstead | Belsize Park to Hampstead | (SG5) Delivery | Under Construction | Yes | 2.008 | 2023-11-21 00:00:00+00:00 | 2000 | ... | 269 | 270 | E09000007 | Camden | 527491 | 184283 | -0.16291 | 51.54305 | 88f3f650-53ac-434d-883e-6235b48d14c4 | |
| 16 | C6 | Cycleways | Elephant and Castle to Hampstead | Belsize Park to Kentish Town | Complete | Complete | Yes | 0.822 | 2023-11-21 00:00:00+00:00 | 2007 | ... | 269 | 270 | E09000007 | Camden | 527491 | 184283 | -0.16291 | 51.54305 | 88f3f650-53ac-434d-883e-6235b48d14c4 | |
| 45 | C | Cycleways | Chalk Farm to Swiss Cottage | Chalk Farm to Swiss Cottage | (SG3) Concept Design | Feasibility | Yes | 1.648 | 2023-11-21 00:00:00+00:00 | 2036 | ... | 269 | 270 | E09000007 | Camden | 527491 | 184283 | -0.16291 | 51.54305 | 88f3f650-53ac-434d-883e-6235b48d14c4 | |
| 46 | C | Cycleways | Elephant and Castle to Hampstead | Kentish Town to Hampstead Heath | (SG4) Detailed Design | Feasibility | Yes | 0.344 | 2023-11-21 00:00:00+00:00 | 2037 | ... | 269 | 270 | E09000007 | Camden | 527491 | 184283 | -0.16291 | 51.54305 | 88f3f650-53ac-434d-883e-6235b48d14c4 | |
| 48 | C41 | Central London Grid | Eversholt Street to Midland Road | Eversholt Street to Midland Road | (SG2) Option Selection | Complete | Yes | 0.496 | 2023-11-21 00:00:00+00:00 | 2039 | ... | 269 | 270 | E09000007 | Camden | 527491 | 184283 | -0.16291 | 51.54305 | 88f3f650-53ac-434d-883e-6235b48d14c4 | |
| 75 | C | Cycleways | St Pancras to Kentish Town | St Pancras to Kentish Town | Complete | Complete | Yes | 1.195 | 2023-11-21 00:00:00+00:00 | 2066 | ... | 269 | 270 | E09000007 | Camden | 527491 | 184283 | -0.16291 | 51.54305 | 88f3f650-53ac-434d-883e-6235b48d14c4 | |
| 162 | C | Cycleways | Elephant and Castle to Hampstead | Castlehaven Grafton Road | Complete | Complete | Yes | 1.833 | 2023-11-21 00:00:00+00:00 | 2153 | ... | 269 | 270 | E09000007 | Camden | 527491 | 184283 | -0.16291 | 51.54305 | 88f3f650-53ac-434d-883e-6235b48d14c4 |
8 rows × 22 columns
# Plot Camden boundary and its cycle routes
fig, ax = plt.subplots(figsize=(6, 6))
gdf_camden.plot(ax=ax, edgecolor='black', color='skyblue', alpha=0.4)
gdf_camden_cycle_routes.plot(ax=ax, color='royalblue', alpha=1, linewidth=2)
ax.set_axis_off()
Q4 solution:
# Select the cycle route we used in the buffer example, we have used the gdf_cr_s (['OBJECTID' == 2096]) before.
gdf_cr_s
| LABEL | PROGRAMME | ROUTE_NAME | ROUTE | MILESTONE | STATUS | PUBLIC_ | ROUTE_LENGTH_KM | PROGRAMME_UPDATED | OBJECTID | Shape__Length | geometry | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 105 | C5 | Cycleways | Waterloo to Clapham | Waterloo to Clapham | Complete | Complete | Yes | 5.814 | 2023-11-21 00:00:00+00:00 | 2096 | 5814.364404 | LINESTRING Z (528800.09 174090.413 0, 528776.0... |
# We also have created the 500m buffer for this cycle route (cr_s_buffer_500).
cr_s_buffer_500
105 POLYGON ((528187.268 174633.775, 528216.987 17...
dtype: geometry
# We need to transfer the geoseries to the geodataframe (add the 500m info) as input in the next spatial join.
gdf_cr_s_buffer_500 = gpd.GeoDataFrame(geometry=cr_s_buffer_500)
gdf_cr_s_buffer_500['buffer'] = '500m'
gdf_cr_s_buffer_500
| geometry | buffer | |
|---|---|---|
| 105 | POLYGON ((528187.268 174633.775, 528216.987 17... | 500m |
# Spatial join: 7 stations within the 500m buffer area.
gdf_cr_underground_buffer_500 = gpd.sjoin(gdf_underground, gdf_cr_s_buffer_500, how='inner', predicate='intersects')
gdf_cr_underground_buffer_500
| OBJECTID | NAME | LINES | ATCOCODE | MODES | ACCESSIBILITY | NIGHT_TUBE | NETWORK | DATASET_LAST_UPDATED | FULL_NAME | geometry | index_right | buffer | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 77 | 188 | Vauxhall | Victoria | 940GZZLUVXL | tube | Not Accessible | Yes | London Underground | 2021-11-29 00:00:00+00:00 | Vauxhall station | POINT Z (530336.807 177973.008 0) | 105 | 500m |
| 115 | 226 | Clapham South | Northern | 940GZZLUCPS | tube, bus | Not Accessible | Yes | London Underground | 2021-11-29 00:00:00+00:00 | Clapham South station | POINT Z (528834.045 174322.71 0) | 105 | 500m |
| 116 | 227 | Clapham Common | Northern | 940GZZLUCPC | tube, bus | Not Accessible | Yes | London Underground | 2021-11-29 00:00:00+00:00 | Clapham Common station | POINT Z (529504.822 175338.252 0) | 105 | 500m |
| 117 | 228 | Clapham North | Northern | 940GZZLUCPN | tube, bus | Partially Accessible - Interchange Only | Yes | London Underground | 2021-11-29 00:00:00+00:00 | Clapham North station | POINT Z (530038.978 175743.455 0) | 105 | 500m |
| 125 | 236 | Oval | Northern | 940GZZLUOVL | bus, tube | Not Accessible | Yes | London Underground | 2021-11-29 00:00:00+00:00 | Oval station | POINT Z (531170.311 177564.906 0) | 105 | 500m |
| 184 | 295 | Stockwell | Northern, Victoria | 940GZZLUSKW | bus, tube | Partially Accessible - Interchange Only | Yes | London Underground | 2021-11-29 00:00:00+00:00 | Stockwell station | POINT Z (530460.348 176432.891 0) | 105 | 500m |
| 227 | 380 | Nine Elms | Northern | None | tube | None | Yes | London Underground | 2021-11-29 00:00:00+00:00 | Nine Elms station | POINT Z (529989.269 177345.632 0) | 105 | 500m |
# Then, we create the 100m buffer for this cycle route and create the geodataframe.
cr_s_buffer_1000 = gdf_cr_s.buffer(1000)
gdf_cr_s_buffer_1000 = gpd.GeoDataFrame(geometry=cr_s_buffer_1000)
gdf_cr_s_buffer_1000['buffer'] = '1000m'
gdf_cr_s_buffer_1000
| geometry | buffer | |
|---|---|---|
| 105 | POLYGON ((527794.412 174945.879, 527800.962 17... | 1000m |
# Spatial join: 10 rows within the 1000m buffer area.
gdf_cr_underground_buffer_1000 = gpd.sjoin(gdf_underground, gdf_cr_s_buffer_1000, how='inner', predicate='intersects')
gdf_cr_underground_buffer_1000
| OBJECTID | NAME | LINES | ATCOCODE | MODES | ACCESSIBILITY | NIGHT_TUBE | NETWORK | DATASET_LAST_UPDATED | FULL_NAME | geometry | index_right | buffer | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 76 | 187 | Pimlico | Victoria | 940GZZLUPCO | tube, bus | Not Accessible | Yes | London Underground | 2021-11-29 00:00:00+00:00 | Pimlico station | POINT Z (529670.659 178332.6 0) | 105 | 1000m |
| 77 | 188 | Vauxhall | Victoria | 940GZZLUVXL | tube | Not Accessible | Yes | London Underground | 2021-11-29 00:00:00+00:00 | Vauxhall station | POINT Z (530336.807 177973.008 0) | 105 | 1000m |
| 115 | 226 | Clapham South | Northern | 940GZZLUCPS | tube, bus | Not Accessible | Yes | London Underground | 2021-11-29 00:00:00+00:00 | Clapham South station | POINT Z (528834.045 174322.71 0) | 105 | 1000m |
| 116 | 227 | Clapham Common | Northern | 940GZZLUCPC | tube, bus | Not Accessible | Yes | London Underground | 2021-11-29 00:00:00+00:00 | Clapham Common station | POINT Z (529504.822 175338.252 0) | 105 | 1000m |
| 117 | 228 | Clapham North | Northern | 940GZZLUCPN | tube, bus | Partially Accessible - Interchange Only | Yes | London Underground | 2021-11-29 00:00:00+00:00 | Clapham North station | POINT Z (530038.978 175743.455 0) | 105 | 1000m |
| 125 | 236 | Oval | Northern | 940GZZLUOVL | bus, tube | Not Accessible | Yes | London Underground | 2021-11-29 00:00:00+00:00 | Oval station | POINT Z (531170.311 177564.906 0) | 105 | 1000m |
| 126 | 237 | Kennington | Northern | 940GZZLUKNG | tube, bus | Partially Accessible - Interchange Only | Yes | London Underground | 2021-11-29 00:00:00+00:00 | Kennington station | POINT Z (531598.816 178299.56 0) | 105 | 1000m |
| 184 | 295 | Stockwell | Northern, Victoria | 940GZZLUSKW | bus, tube | Partially Accessible - Interchange Only | Yes | London Underground | 2021-11-29 00:00:00+00:00 | Stockwell station | POINT Z (530460.348 176432.891 0) | 105 | 1000m |
| 227 | 380 | Nine Elms | Northern | None | tube | None | Yes | London Underground | 2021-11-29 00:00:00+00:00 | Nine Elms station | POINT Z (529989.269 177345.632 0) | 105 | 1000m |
| 252 | 440 | Balham | Northern | 940GZZLUBLM | tube | Not Accessible | Yes | London Underground | 2021-11-29 00:00:00+00:00 | Balham station | POINT Z (528480.339 173244.484 0) | 105 | 1000m |
# We can output the names of station names within the 500m and 500-1000m buffer areas of this cycle route.
print('stations within 500m', gdf_cr_underground_buffer_500.NAME.to_list())
print('stations within 500-1000m', set(gdf_cr_underground_buffer_1000.NAME.to_list()) - set(gdf_cr_underground_buffer_500.NAME.to_list()))
stations within 500m ['Vauxhall', 'Clapham South', 'Clapham Common', 'Clapham North', 'Oval', 'Stockwell', 'Nine Elms']
stations within 500-1000m {'Kennington', 'Balham', 'Pimlico'}
# Plot the cycle route, the buffer areas, and the related underground stations.
fig, ax = plt.subplots(figsize=(6, 6))
gdf_cr_s.plot(ax=ax, edgecolor='black', color='royalblue', alpha=1, linewidth=2)
gdf_cr_s_buffer_500.plot(ax=ax, edgecolor='grey', color='royalblue', alpha=0.3, linewidth=0.4)
gdf_cr_s_buffer_1000.plot(ax=ax, edgecolor='grey', color='royalblue', alpha=0.3, linewidth=0.4)
gdf_cr_underground_buffer_500.plot(ax=ax, edgecolor='grey', color='red', alpha=1, markersize=50, label='Stations within 500m')
gdf_cr_underground_buffer_1000[gdf_cr_underground_buffer_1000.NAME.isin(['Pimlico', 'Balham', 'Kennington'])].plot(ax=ax, edgecolor='grey', color='orange', alpha=1, markersize=50, label='Stations within 500-1000m')
ax.legend(loc='upper left')
ax.set_axis_off()
Q5 solution:
# Select the underground stations in the Central line.
gdf_central_line_stations = gdf_underground[gdf_underground['LINES'].str.contains('Central')]
gdf_central_line_stations
| OBJECTID | NAME | LINES | ATCOCODE | MODES | ACCESSIBILITY | NIGHT_TUBE | NETWORK | DATASET_LAST_UPDATED | FULL_NAME | geometry | |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | 111 | St. Paul's | Central | 940GZZLUSPU | bus, tube | Not Accessible | Yes | London Underground | 2021-11-29 00:00:00+00:00 | St. Paul's station | POINT Z (532108.364 181274.192 0) |
| 1 | 112 | Mile End | District, Hammersmith & City, Central | 940GZZLUMED | bus, tube | Partially Accessible - Interchange Only | Yes | London Underground | 2021-11-29 00:00:00+00:00 | Mile End station | POINT Z (536500.796 182534.495 0) |
| 2 | 113 | Bethnal Green | Central | 940GZZLUBLG | bus, tube | Not Accessible | Yes | London Underground | 2021-11-29 00:00:00+00:00 | Bethnal Green station | POINT Z (535043.555 182718.413 0) |
| 3 | 114 | Leyton | Central | 940GZZLULYN | bus, tube | Not Accessible | Yes | London Underground | 2021-11-29 00:00:00+00:00 | Leyton station | POINT Z (538367.45 186075.857 0) |
| 4 | 115 | Snaresbrook | Central | 940GZZLUSNB | bus, tube | Not Accessible | Yes | London Underground | 2021-11-29 00:00:00+00:00 | Snaresbrook station | POINT Z (540156.785 188804.046 0) |
| 5 | 116 | Leytonstone | Central | 940GZZLULYS | bus, tube | Not Accessible | Yes | London Underground | 2021-11-29 00:00:00+00:00 | Leytonstone station | POINT Z (539279.289 187404.74 0) |
| 6 | 117 | Wanstead | Central | 940GZZLUWSD | bus, tube | Not Accessible | Yes | London Underground | 2021-11-29 00:00:00+00:00 | Wanstead station | POINT Z (540673.165 188253.511 0) |
| 7 | 118 | South Woodford | Central | 940GZZLUSWF | bus, tube | Partially Accessible | Yes | London Underground | 2021-11-29 00:00:00+00:00 | South Woodford station | POINT Z (540535.749 190062.673 0) |
| 8 | 119 | Newbury Park | Central | 940GZZLUNBP | tube, bus | Not Accessible | Yes | London Underground | 2021-11-29 00:00:00+00:00 | Newbury Park station | POINT Z (544920.305 188384.723 0) |
| 9 | 120 | Barkingside | Central | 940GZZLUBKE | tube, bus | Partially Accessible | Yes | London Underground | 2021-11-29 00:00:00+00:00 | Barkingside station | POINT Z (544798.769 189493.952 0) |
| 10 | 121 | Fairlop | Central | 940GZZLUFLP | tube | Not Accessible | Yes | London Underground | 2021-11-29 00:00:00+00:00 | Fairlop station | POINT Z (544935.611 190594.577 0) |
| 11 | 122 | Woodford | Central | 940GZZLUWOF | tube, bus | Fully Accessible | Yes | London Underground | 2021-11-29 00:00:00+00:00 | Woodford station | POINT Z (540949.994 191740.022 0) |
| 12 | 123 | Roding Valley | Central | 940GZZLURVY | tube | Fully Accessible | No | London Underground | 2021-11-29 00:00:00+00:00 | Roding Valley station | POINT Z (541589.716 192894.967 0) |
| 13 | 124 | Chigwell | Central | 940GZZLUCWL | bus, tube | Not Accessible | No | London Underground | 2021-11-29 00:00:00+00:00 | Chigwell station | POINT Z (543795.214 193021.043 0) |
| 18 | 129 | Ruislip Gardens | Central | 940GZZLURSG | tube, bus | Not Accessible | No | London Underground | 2021-11-29 00:00:00+00:00 | Ruislip Gardens station | POINT Z (510266.41 185851.603 0) |
| 19 | 130 | South Ruislip | Central | 940GZZLUSRP | tube | Not Accessible | No | London Underground | 2021-11-29 00:00:00+00:00 | South Ruislip station | POINT Z (511097.397 185434.108 0) |
| 20 | 131 | Northolt | Central | 940GZZLUNHT | tube, bus | Not Accessible | No | London Underground | 2021-11-29 00:00:00+00:00 | Northolt station | POINT Z (513213.344 184523.901 0) |
| 21 | 132 | West Ruislip | Central | 940GZZLUWRP | tube | Not Accessible | No | London Underground | 2021-11-29 00:00:00+00:00 | West Ruislip station | POINT Z (508378.676 186796 0) |
| 52 | 163 | Liverpool Street | Metropolitan, Central, Circle, Hammersmith & City | 940GZZLULVT | tube | Partially Accessible | Yes | London Underground | 2021-11-29 00:00:00+00:00 | Liverpool Street station | POINT Z (533093.866 181566.922 0) |
| 70 | 181 | White City | Central | 940GZZLUWCY | bus, tube | Not Accessible | Yes | London Underground | 2021-11-29 00:00:00+00:00 | White City station | POINT Z (523307.836 180748.42 0) |
| 71 | 182 | Shepherd's Bush | Central | 940GZZLUSBC | tube | Not Accessible | Yes | London Underground | 2021-11-29 00:00:00+00:00 | Shepherd's Bush station | POINT Z (523719.584 179883.562 0) |
| 72 | 183 | Holland Park | Central | 940GZZLUHPK | bus, tube | Not Accessible | Yes | London Underground | 2021-11-29 00:00:00+00:00 | Holland Park station | POINT Z (524626.261 180217.356 0) |
| 90 | 201 | Notting Hill Gate | District, Central, Circle | 940GZZLUNHG | bus, tube | Not Accessible | Yes | London Underground | 2021-11-29 00:00:00+00:00 | Notting Hill Gate station | POINT Z (525284.928 180456.362 0) |
| 91 | 202 | Lancaster Gate | Central | 940GZZLULGT | tube, bus | Not Accessible | Yes | London Underground | 2021-11-29 00:00:00+00:00 | Lancaster Gate station | POINT Z (526710.521 180773.352 0) |
| 92 | 203 | Marble Arch | Central | 940GZZLUMBA | tube, bus | Not Accessible | Yes | London Underground | 2021-11-29 00:00:00+00:00 | Marble Arch station | POINT Z (527960.144 181017.479 0) |
| 93 | 204 | Bond Street | Central, Jubilee | 940GZZLUBND | tube, bus | Fully Accessible | Yes | London Underground | 2021-11-29 00:00:00+00:00 | Bond Street station | POINT Z (528490.686 181117.639 0) |
| 94 | 205 | Perivale | Central | 940GZZLUPVL | bus, tube | Not Accessible | No | London Underground | 2021-11-29 00:00:00+00:00 | Perivale station | POINT Z (516378.363 183314.993 0) |
| 95 | 206 | Greenford | Central | 940GZZLUGFD | tube | Partially Accessible - Interchange Only | No | London Underground | 2021-11-29 00:00:00+00:00 | Greenford station | POINT Z (514763.109 183928.056 0) |
| 96 | 207 | North Acton | Central | 940GZZLUNAN | bus, tube | Not Accessible | No | London Underground | 2021-11-29 00:00:00+00:00 | North Acton station | POINT Z (520828.415 181956.943 0) |
| 98 | 209 | Bank | Waterloo & City, Northern, Central | 940GZZLUBNK | tube | Not Accessible | Yes | London Underground | 2021-11-29 00:00:00+00:00 | Bank station | POINT Z (532710.168 181119.901 0) |
| 99 | 210 | Oxford Circus | Central, Bakerloo, Victoria | 940GZZLUOXC | tube, bus | Partially Accessible - Interchange Only | Yes | London Underground | 2021-11-29 00:00:00+00:00 | Oxford Circus station | POINT Z (529046.627 181236.34 0) |
| 100 | 211 | Holborn | Central, Piccadilly | 940GZZLUHBN | tube, bus | Not Accessible | Yes | London Underground | 2021-11-29 00:00:00+00:00 | Holborn station | POINT Z (530512.074 181525.075 0) |
| 101 | 212 | Chancery Lane | Central | 940GZZLUCHL | tube, bus | Not Accessible | Yes | London Underground | 2021-11-29 00:00:00+00:00 | Chancery Lane station | POINT Z (531123.959 181615.469 0) |
| 119 | 230 | Tottenham Court Road | Central, Northern | 940GZZLUTCR | bus, tube | Fully Accessible | Yes | London Underground | 2021-11-29 00:00:00+00:00 | Tottenham Court Road station | POINT Z (529815.394 181382.5 0) |
| 127 | 238 | East Acton | Central | 940GZZLUEAN | bus, tube | Not Accessible | Yes | London Underground | 2021-11-29 00:00:00+00:00 | East Acton station | POINT Z (521721.012 181197.774 0) |
| 134 | 245 | Queensway | Central | 940GZZLUQWY | bus, tube | Not Accessible | Yes | London Underground | 2021-11-29 00:00:00+00:00 | Queensway station | POINT Z (525903.093 180593.609 0) |
| 135 | 246 | Buckhurst Hill | Central | 940GZZLUBKH | tube, bus | Not Accessible | Yes | London Underground | 2021-11-29 00:00:00+00:00 | Buckhurst Hill station | POINT Z (541777.578 193891.183 0) |
| 136 | 247 | Loughton | Central | 940GZZLULGN | tube, bus | Not Accessible | Yes | London Underground | 2021-11-29 00:00:00+00:00 | Loughton station | POINT Z (542318.902 195612.391 0) |
| 137 | 248 | Hainault | Central | 940GZZLUHLT | tube, bus | Fully Accessible | Yes | London Underground | 2021-11-29 00:00:00+00:00 | Hainault station | POINT Z (545079.906 191498.186 0) |
| 138 | 249 | Grange Hill | Central | 940GZZLUGGH | tube, bus | Not Accessible | No | London Underground | 2021-11-29 00:00:00+00:00 | Grange Hill station | POINT Z (544967.323 192558.695 0) |
| 139 | 250 | Debden | Central | 940GZZLUDBN | tube | Partially Accessible | No | London Underground | 2021-11-29 00:00:00+00:00 | Debden station | POINT Z (544272.935 196121.785 0) |
| 140 | 251 | Epping | Central | 940GZZLUEPG | tube | Fully Accessible | No | London Underground | 2021-11-29 00:00:00+00:00 | Epping station | POINT Z (546209.443 201538.403 0) |
| 141 | 252 | Redbridge | Central | 940GZZLURBG | bus, tube | Not Accessible | Yes | London Underground | 2021-11-29 00:00:00+00:00 | Redbridge station | POINT Z (541834.499 188358.005 0) |
| 179 | 290 | Ealing Broadway | District, Central | 940GZZLUEBY | tube | Partially Accessible - Interchange Only | Yes | London Underground | 2021-11-29 00:00:00+00:00 | Ealing Broadway station | POINT Z (517989.361 180932.53 0) |
| 205 | 316 | West Acton | Central | 940GZZLUWTA | bus, tube | Not Accessible | Yes | London Underground | 2021-11-29 00:00:00+00:00 | West Acton station | POINT Z (519372.874 181295.928 0) |
| 206 | 317 | Stratford | Central, Jubilee | 940GZZLUSTD | tube | Fully Accessible | Yes | London Underground | 2021-11-29 00:00:00+00:00 | Stratford station | POINT Z (538530.061 184394.649 0) |
| 237 | 393 | Hanger Lane | Central | 940GZZLUHGR | tube, bus | Not Accessible | No | London Underground | 2021-11-29 00:00:00+00:00 | Hanger Lane station | POINT Z (518527.328 182634.182 0) |
| 238 | 394 | Gants Hill | Central | 940GZZLUGTH | bus, tube | Not Accessible | Yes | London Underground | 2021-11-29 00:00:00+00:00 | Gants Hill station | POINT Z (543273.691 188430.211 0) |
| 269 | 484 | Theydon Bois | Central | 940GZZLUTHB | tube | Partially Accessible | No | London Underground | 2021-11-29 00:00:00+00:00 | Theydon Bois station | POINT Z (545541.525 199100.831 0) |
# We can plot the selected 49 stations.
fig, ax = plt.subplots(figsize=(6, 6))
gdf_london_bound.plot(ax=ax, edgecolor='grey', color='skyblue', alpha=0.4, linewidth=0.4)
gdf_central_line_stations.plot(ax=ax, edgecolor='grey', color='red', alpha=0.7, lw=0.5, markersize=5)
<Axes: >
# We create the 500m buffer for the central line underground stations.
central_line_stations_buffer_500 = gdf_central_line_stations.buffer(500)
gdf_central_line_stations_buffer_500 = gpd.GeoDataFrame(geometry=central_line_stations_buffer_500)
gdf_central_line_stations_buffer_500['buffer'] = '500m'
gdf_central_line_stations_buffer_500
| geometry | buffer | |
|---|---|---|
| 0 | POLYGON ((532608.364 181274.192, 532605.956 18... | 500m |
| 1 | POLYGON ((537000.796 182534.495, 536998.388 18... | 500m |
| 2 | POLYGON ((535543.555 182718.413, 535541.147 18... | 500m |
| 3 | POLYGON ((538867.45 186075.857, 538865.042 186... | 500m |
| 4 | POLYGON ((540656.785 188804.046, 540654.377 18... | 500m |
| 5 | POLYGON ((539779.289 187404.74, 539776.882 187... | 500m |
| 6 | POLYGON ((541173.165 188253.511, 541170.757 18... | 500m |
| 7 | POLYGON ((541035.749 190062.673, 541033.342 19... | 500m |
| 8 | POLYGON ((545420.305 188384.723, 545417.897 18... | 500m |
| 9 | POLYGON ((545298.769 189493.952, 545296.361 18... | 500m |
| 10 | POLYGON ((545435.611 190594.577, 545433.204 19... | 500m |
| 11 | POLYGON ((541449.994 191740.022, 541447.586 19... | 500m |
| 12 | POLYGON ((542089.716 192894.967, 542087.308 19... | 500m |
| 13 | POLYGON ((544295.214 193021.043, 544292.807 19... | 500m |
| 18 | POLYGON ((510766.41 185851.603, 510764.003 185... | 500m |
| 19 | POLYGON ((511597.397 185434.108, 511594.99 185... | 500m |
| 20 | POLYGON ((513713.344 184523.901, 513710.937 18... | 500m |
| 21 | POLYGON ((508878.676 186796, 508876.268 186746... | 500m |
| 52 | POLYGON ((533593.866 181566.922, 533591.458 18... | 500m |
| 70 | POLYGON ((523807.836 180748.42, 523805.429 180... | 500m |
| 71 | POLYGON ((524219.584 179883.562, 524217.176 17... | 500m |
| 72 | POLYGON ((525126.261 180217.356, 525123.853 18... | 500m |
| 90 | POLYGON ((525784.928 180456.362, 525782.52 180... | 500m |
| 91 | POLYGON ((527210.521 180773.352, 527208.114 18... | 500m |
| 92 | POLYGON ((528460.144 181017.479, 528457.736 18... | 500m |
| 93 | POLYGON ((528990.686 181117.639, 528988.279 18... | 500m |
| 94 | POLYGON ((516878.363 183314.993, 516875.955 18... | 500m |
| 95 | POLYGON ((515263.109 183928.056, 515260.701 18... | 500m |
| 96 | POLYGON ((521328.415 181956.943, 521326.007 18... | 500m |
| 98 | POLYGON ((533210.168 181119.901, 533207.76 181... | 500m |
| 99 | POLYGON ((529546.627 181236.34, 529544.219 181... | 500m |
| 100 | POLYGON ((531012.074 181525.075, 531009.667 18... | 500m |
| 101 | POLYGON ((531623.959 181615.469, 531621.551 18... | 500m |
| 119 | POLYGON ((530315.394 181382.5, 530312.986 1813... | 500m |
| 127 | POLYGON ((522221.012 181197.774, 522218.605 18... | 500m |
| 134 | POLYGON ((526403.093 180593.609, 526400.686 18... | 500m |
| 135 | POLYGON ((542277.578 193891.183, 542275.171 19... | 500m |
| 136 | POLYGON ((542818.902 195612.391, 542816.494 19... | 500m |
| 137 | POLYGON ((545579.906 191498.186, 545577.498 19... | 500m |
| 138 | POLYGON ((545467.323 192558.695, 545464.916 19... | 500m |
| 139 | POLYGON ((544772.935 196121.785, 544770.528 19... | 500m |
| 140 | POLYGON ((546709.443 201538.403, 546707.036 20... | 500m |
| 141 | POLYGON ((542334.499 188358.005, 542332.092 18... | 500m |
| 179 | POLYGON ((518489.361 180932.53, 518486.953 180... | 500m |
| 205 | POLYGON ((519872.874 181295.928, 519870.467 18... | 500m |
| 206 | POLYGON ((539030.061 184394.649, 539027.653 18... | 500m |
| 237 | POLYGON ((519027.328 182634.182, 519024.921 18... | 500m |
| 238 | POLYGON ((543773.691 188430.211, 543771.283 18... | 500m |
| 269 | POLYGON ((546041.525 199100.831, 546039.117 19... | 500m |
# Spatial join between gdf_central_line_stations_buffer_500 and the cycle routes (gdf_cycle_routes_s).
gdf_cl_station_buffer_cycle = gpd.sjoin(gdf_cycle_routes_s, gdf_central_line_stations_buffer_500, how='inner', predicate='crosses')
gdf_cl_station_buffer_cycle
| LABEL | PROGRAMME | ROUTE_NAME | ROUTE | MILESTONE | STATUS | PUBLIC_ | ROUTE_LENGTH_KM | PROGRAMME_UPDATED | OBJECTID | Shape__Length | geometry | index_right | buffer | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 4 | C41 | Cycleways | Euston to Holborn | Euston to Holborn | Complete | Complete | Yes | 1.181 | 2023-11-21 00:00:00+00:00 | 1995 | 1180.878708 | LINESTRING Z (530256.221 182467.95 0, 530287.0... | 100 | 500m |
| 4 | C41 | Cycleways | Euston to Holborn | Euston to Holborn | Complete | Complete | Yes | 1.181 | 2023-11-21 00:00:00+00:00 | 1995 | 1180.878708 | LINESTRING Z (530256.221 182467.95 0, 530287.0... | 101 | 500m |
| 5 | C55 | Cycleways | Lancaster Gate to Hyde Park Corner | Lancaster Gate to Hyde Park Corner | Complete | Complete | Yes | 0.723 | 2023-11-21 00:00:00+00:00 | 1996 | 723.280344 | LINESTRING Z (526926.013 180815.005 0, 526936.... | 91 | 500m |
| 5 | C55 | Cycleways | Lancaster Gate to Hyde Park Corner | Lancaster Gate to Hyde Park Corner | Complete | Complete | Yes | 0.723 | 2023-11-21 00:00:00+00:00 | 1996 | 723.280344 | LINESTRING Z (526926.013 180815.005 0, 526936.... | 92 | 500m |
| 7 | C49 | Cycleways | Acton to Chiswick | Acton to Chiswick | Complete | Complete | Yes | 4.210 | 2023-11-21 00:00:00+00:00 | 1998 | 4209.703771 | LINESTRING Z (521096.17 178513.522 0, 521106.7... | 127 | 500m |
| 12 | C55 | Cycleways | Lancaster Gate to Hyde Park Corner | Lancaster Gate to Hyde Park Corner | Complete | Complete | Yes | 1.439 | 2023-11-21 00:00:00+00:00 | 2003 | 1438.814951 | LINESTRING Z (527615.936 180858.038 0, 527864.... | 92 | 500m |
| 22 | C3 | Cycleways | Lancaster Gate to Barking | Lancaster Gate to Barking | Complete | Complete | Yes | 22.425 | 2023-11-21 00:00:00+00:00 | 2013 | 22425.196420 | LINESTRING Z (545213.627 183267.215 0, 545181.... | 91 | 500m |
| 22 | C3 | Cycleways | Lancaster Gate to Barking | Lancaster Gate to Barking | Complete | Complete | Yes | 22.425 | 2023-11-21 00:00:00+00:00 | 2013 | 22425.196420 | LINESTRING Z (545213.627 183267.215 0, 545181.... | 98 | 500m |
| 22 | C3 | Cycleways | Lancaster Gate to Barking | Lancaster Gate to Barking | Complete | Complete | Yes | 22.425 | 2023-11-21 00:00:00+00:00 | 2013 | 22425.196420 | LINESTRING Z (545213.627 183267.215 0, 545181.... | 0 | 500m |
| 32 | C | Cycleways | Cambridge Park Road | Cambridge Park Road | (SG3) Concept Design | Feasibility | Yes | 0.727 | 2023-11-21 00:00:00+00:00 | 2023 | 726.518206 | LINESTRING Z (540022.631 187873.251 0, 540116.... | 6 | 500m |
| 42 | C11 | Cycleways | Essex Road to Farringdon | The City to Farringdon | Complete | Complete | Yes | 1.243 | 2023-11-21 00:00:00+00:00 | 2033 | 1243.120260 | LINESTRING Z (532589.5 181938.471 0, 532573.01... | 0 | 500m |
| 42 | C11 | Cycleways | Essex Road to Farringdon | The City to Farringdon | Complete | Complete | Yes | 1.243 | 2023-11-21 00:00:00+00:00 | 2033 | 1243.120260 | LINESTRING Z (532589.5 181938.471 0, 532573.01... | 101 | 500m |
| 47 | C | Cycleways | Lancaster Gate to Noting Hill Gate | Lancaster Gate to Noting Hill Gate | (SG3) Concept Design | Feasibility | Yes | 1.234 | 2023-11-21 00:00:00+00:00 | 2038 | 1234.267070 | LINESTRING Z (525596.616 180551.655 0, 525725.... | 90 | 500m |
| 47 | C | Cycleways | Lancaster Gate to Noting Hill Gate | Lancaster Gate to Noting Hill Gate | (SG3) Concept Design | Feasibility | Yes | 1.234 | 2023-11-21 00:00:00+00:00 | 2038 | 1234.267070 | LINESTRING Z (525596.616 180551.655 0, 525725.... | 134 | 500m |
| 47 | C | Cycleways | Lancaster Gate to Noting Hill Gate | Lancaster Gate to Noting Hill Gate | (SG3) Concept Design | Feasibility | Yes | 1.234 | 2023-11-21 00:00:00+00:00 | 2038 | 1234.267070 | LINESTRING Z (525596.616 180551.655 0, 525725.... | 91 | 500m |
| 81 | C2 | Cycleways | Aldgate to Stratford | Aldgate to Stratford | Complete | Complete | Yes | 6.370 | 2023-11-21 00:00:00+00:00 | 2072 | 6369.852153 | LINESTRING Z (533742.047 181260.481 0, 533770.... | 1 | 500m |
| 81 | C2 | Cycleways | Aldgate to Stratford | Aldgate to Stratford | Complete | Complete | Yes | 6.370 | 2023-11-21 00:00:00+00:00 | 2072 | 6369.852153 | LINESTRING Z (533742.047 181260.481 0, 533770.... | 206 | 500m |
| 92 | C34 | Cycleways | Wood Lane to Barnes | Wood Lane to Rockley Rd | (SG3) Concept Design | Feasibility | Yes | 2.153 | 2023-11-21 00:00:00+00:00 | 2083 | 2153.202189 | LINESTRING Z (523180.013 181090.003 0, 523251.... | 71 | 500m |
| 92 | C34 | Cycleways | Wood Lane to Barnes | Wood Lane to Rockley Rd | (SG3) Concept Design | Feasibility | Yes | 2.153 | 2023-11-21 00:00:00+00:00 | 2083 | 2153.202189 | LINESTRING Z (523180.013 181090.003 0, 523251.... | 70 | 500m |
| 93 | C34 | Cycleways | Wood Lane to Acton | Wood Lane to Acton | Complete | Complete | Yes | 3.408 | 2023-11-21 00:00:00+00:00 | 2084 | 3407.905733 | LINESTRING Z (523180.013 181090.003 0, 523165.... | 70 | 500m |
| 93 | C34 | Cycleways | Wood Lane to Acton | Wood Lane to Acton | Complete | Complete | Yes | 3.408 | 2023-11-21 00:00:00+00:00 | 2084 | 3407.905733 | LINESTRING Z (523180.013 181090.003 0, 523165.... | 127 | 500m |
| 93 | C34 | Cycleways | Wood Lane to Acton | Wood Lane to Acton | Complete | Complete | Yes | 3.408 | 2023-11-21 00:00:00+00:00 | 2084 | 3407.905733 | LINESTRING Z (523180.013 181090.003 0, 523165.... | 96 | 500m |
| 103 | C | Central London Grid | Fitzrovia to Soho | Fitzrovia to Soho | (SG4) Detailed Design | Feasibility | Yes | 0.942 | 2023-11-21 00:00:00+00:00 | 2094 | 942.260282 | LINESTRING Z (529476.013 181246.003 25.5, 5295... | 99 | 500m |
| 103 | C | Central London Grid | Fitzrovia to Soho | Fitzrovia to Soho | (SG4) Detailed Design | Feasibility | Yes | 0.942 | 2023-11-21 00:00:00+00:00 | 2094 | 942.260282 | LINESTRING Z (529476.013 181246.003 25.5, 5295... | 119 | 500m |
| 123 | None | Cycleways | Kensington High St to Blenheim Crescent | Kensington High St to Blenheim Crescent | (SG5) Delivery | In Progress | Yes | 1.858 | 2023-11-21 00:00:00+00:00 | 2114 | 1857.573185 | LINESTRING Z (524958.013 179244.005 0, 524943.... | 72 | 500m |
| 125 | None | Cycleways | Clarendon Road Chepstow Villas | Clarendon Road ? Chepstow Villas | (SG5) Delivery | In Progress | Yes | 1.364 | 2023-11-21 00:00:00+00:00 | 2116 | 1363.644025 | LINESTRING Z (524989.013 180863.004 0, 524920.... | 72 | 500m |
| 137 | C | Cycleways | Palace Gate to Black Lion Gate (Kensington Gar... | Palace Gate to Black Lion Gate (Kensington Gar... | Complete | Complete | Yes | 0.965 | 2023-11-21 00:00:00+00:00 | 2128 | 964.976998 | LINESTRING Z (526121.125 179658.722 0, 526116.... | 134 | 500m |
| 140 | C | Cycleways | Upper Brook Street Gate | Upper Brook Street Gate | Complete | Complete | Yes | 1.236 | 2023-11-21 00:00:00+00:00 | 2131 | 1235.978818 | LINESTRING Z (527615.936 180858.038 0, 527672.... | 92 | 500m |
| 165 | C39 | Cycleways | Kensington High St to Shepherds Bush | Kensington High St to Shepherds Bush | Complete | Complete | Yes | 1.151 | 2023-11-21 00:00:00+00:00 | 2156 | 1151.249368 | LINESTRING Z (524567.603 179008.18 0, 524508.3... | 71 | 500m |
# Plot the 29 cycle routes, the related underground stations and the buffer areas.
fig, ax = plt.subplots(figsize=(8, 6))
gdf_central_line_stations.plot(ax=ax, color='red', markersize=4, alpha=1)
gdf_central_line_stations_buffer_500.plot(ax=ax, edgecolor='grey', color='lightgreen', alpha=0.6, linewidth=0.7)
gdf_cl_station_buffer_cycle.plot(ax=ax, color='royalblue', alpha=1, linewidth=1)
ax.set_axis_off()