-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
r-leyshon
committed
Oct 30, 2023
1 parent
35557f9
commit ee7e172
Showing
1 changed file
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
|
||
# %% | ||
# %% |