this is my first question on StackOverflow :) I'm trying to get coordinates of runways and taxiways in Python using OSMnx.
I was trying to run the following code (I wanted to use this example):
import osmnx as ox
import matplotlib.pyplot as plt
import geopandas as gpd
import contextily as ctx
airport_icao_code = "LFBO" # Toulouse–Blagnac Airport
osm_filter = '["aeroway"~"runway|taxiway|apron|control_tower|control_center|gate|hangar|helipad|heliport|navigationaid|taxilane|terminal|windsock|highway_strip|parking_position|holding_position|airstrip|stopway|tower"]'
# you can find other tags linked to airports here: https://wiki.openstreetmap.org/wiki/Key:aeroway
G = ox.graph_from_place(
airport_icao_code,
simplify=False,
retain_all=True,
truncate_by_edge=True,
buffer_dist=1000,
custom_filter=osm_filter,
)
G = ox.graph_from_place(
airport_icao_code,
simplify=False,
retain_all=True,
truncate_by_edge=True,
buffer_dist=1000,
custom_filter=osm_filter,
)
gdf_nodes, gdf_edges = ox.graph_to_gdfs(G)
gdf_edges.head()
gdf_edges.name.unique()
runway_gdf = gdf_edges.query('name=="14L/32R"')
r_gdf_3857 = runway_gdf.to_crs(epsg=3857) # web mercator projection
runway_gdf_3857 = r_gdf_3857[r_gdf_3857["width"].notna()]
runway_gdf_3857.head()
runway_gdf_3857["geometry"] = runway_gdf_3857.apply(
lambda x: x.geometry.buffer(float(x.width) / 2, cap_style=3), axis=1
)
runway_gdf_3857.head()
r = runway_gdf_3857.dissolve(by="name")
r.head()
Unfortunately, I get some warnings:
Warning (from warnings module):
File "C:\Users\Jas\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\geopandas\geodataframe.py", line 1537
warnings.warn("Geometry column does not contain geometry.")
UserWarning: Geometry column does not contain geometry.
Traceback (most recent call last):
File "C:/Users/Jas/Desktop/jas/Python/gnd/calc_dist.py", line 45, in <module>
runway_gdf_3857["geometry"] = runway_gdf_3857.apply(
File "C:\Users\Jas\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\geopandas\geodataframe.py", line 1538, in __setitem__
super().__setitem__(key, value)
File "C:\Users\Jas\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\pandas\core\frame.py", line 3940, in __setitem__
self._set_item_frame_value(key, value)
File "C:\Users\Jas\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\pandas\core\frame.py", line 4069, in _set_item_frame_value
raise ValueError("Columns must be same length as key")
ValueError: Columns must be same length as key
I have never used geopandas before, so maybe I made some begginer's mistakes :)