Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add OSMWayLoader #166

Merged
merged 18 commits into from
Mar 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ repos:
hooks:
- id: refurb
language: python
language_version: python3.10
language_version: python3.11
stages: [manual]
- repo: https://github.com/FHPythonUtils/LicenseCheck
rev: "2023.1.1"
Expand Down
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased] - 2022-MM-DD
## [Unreleased] - 2023-MM-DD

### Added

Expand All @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- GTFS2Vec Embedder using gtfs2vec model
- OSMOnlineLoader
- OSMPbfLoader
- OSMWayLoader
- Neighbourhood
- H3Neighbourhood
- AdjacencyNeighbourhood
Expand Down
1 change: 1 addition & 0 deletions examples/loaders/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ Examples illustrating the usage of every Loader.
- [GTFSLoader](gtfs_loader.ipynb)
- [OSMOnlineLoader](osm_online_loader.ipynb)
- [OSMPbfLoader](osm_pbf_loader.ipynb)
- [OSMWayLoader](osm_way_loader.ipynb)
6 changes: 3 additions & 3 deletions examples/loaders/geoparquet_loader.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3.8.10 ('.venv': venv)",
"display_name": "Python 3.8.14 ('.venv': venv)",
"language": "python",
"name": "python3"
},
Expand All @@ -111,11 +111,11 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.10"
"version": "3.8.14"
},
"vscode": {
"interpreter": {
"hash": "27588098aedc4e0690c9f009d86804b277352852ed19dd471efc5e9817d4b199"
"hash": "ff171c218963a21ae796a71e1fcf1df45597c5219c663e3cec1d9a9df6951d9c"
}
}
},
Expand Down
167 changes: 167 additions & 0 deletions examples/loaders/osm_way_loader.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
{
"cells": [
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"# OSMWayLoader"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import geopandas as gpd\n",
"import osmnx as ox\n",
"import pandas as pd\n",
"from keplergl import KeplerGl\n",
"import shapely.geometry as shpg\n",
"\n",
"from srai.loaders.osm_way_loader import NetworkType, OSMWayLoader\n",
"from srai.constants import WGS84_CRS"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"## Small area"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"polygon1 = shpg.Polygon(\n",
" [\n",
" (17.1005309, 51.1100158),\n",
" (17.1020436, 51.1100427),\n",
" (17.1021938, 51.1082509),\n",
" (17.1006274, 51.1081027),\n",
" (17.1005201, 51.1099956),\n",
" ]\n",
")\n",
"polygon2 = shpg.Polygon(\n",
" [\n",
" (17.0994473, 51.1084126),\n",
" (17.1023226, 51.1086551),\n",
" (17.1023333, 51.1076312),\n",
" (17.0994473, 51.1083722),\n",
" ]\n",
")\n",
"gdf_place = gpd.GeoDataFrame({\"geometry\": [polygon1, polygon2]}, crs=WGS84_CRS)\n",
"gdf_place.plot()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"osmwl = OSMWayLoader(NetworkType.BIKE)\n",
"gdf_nodes, gdf_edges = osmwl.load(gdf_place)\n",
"ax = gdf_edges.plot(linewidth=1, figsize=(12, 7))\n",
"gdf_nodes.plot(ax=ax, markersize=3, color=\"red\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"gdf_nodes"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"gdf_edges"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"## Bigger area"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"gdf_place = ox.geocode_to_gdf(\"Wroclaw, Poland\")\n",
"gdf_place.plot()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"osmwl = OSMWayLoader(NetworkType.DRIVE)\n",
"gdf_nodes, gdf_edges = osmwl.load(gdf_place)\n",
"ax = gdf_edges.plot(linewidth=1, figsize=(12, 7))\n",
"gdf_nodes.plot(ax=ax, markersize=3, color=\"red\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"gdf_nodes"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"gdf_edges"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3.8.14 ('.venv': venv)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.1"
},
"vscode": {
"interpreter": {
"hash": "ff171c218963a21ae796a71e1fcf1df45597c5219c663e3cec1d9a9df6951d9c"
}
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Loading