Skip to content

Commit

Permalink
feat: Visualise node points
Browse files Browse the repository at this point in the history
  • Loading branch information
r-leyshon committed Oct 30, 2023
1 parent 35557f9 commit ee7e172
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions notebooks/osm/01-visualise-osm.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
"""Visualise OMS spatial features."""
from pyprojroot import here
import pandas as pd
import geopandas as gpd
from shapely import Point
from transport_performance.osm import validate_osm as osmval

# %%
FIX_PTH = here("tests/data/newport-2023-06-13.osm.pbf")

# %%
# get some Node IDs to work with

nodes = osmval.FindIds(FIX_PTH)
nodes.get_feature_ids()
some_IDs = nodes.id_dict["node_ids"][0:100]

# %%
# get the locations
locs = osmval.FindLocations(FIX_PTH)
some_coords = locs.check_locs_for_ids(some_IDs, "node")
# %%
# get the contextual information in the tags, though note these
# be blank for nodes
# tags = osmval.FindTags(FIX_PTH)
# some_tags = tags.check_tags_for_ids(some_IDs, "node")
# all of the found tags are blank. TODO: find a populated example.

# %%
all_coords = pd.DataFrame()
for key, values in some_coords["node"].items():
coord_row = pd.DataFrame(values, index=[key])
all_coords = pd.concat([all_coords, coord_row])

# %%
all_coords["geometry"] = [
Point(xy) for xy in zip(all_coords["lon"], all_coords["lat"])
]

# %%
coords_gdf = gpd.GeoDataFrame(all_coords, crs=4326)
coords_gdf.explore()

# %%
# %%

0 comments on commit ee7e172

Please sign in to comment.