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 osm data loader based on pbf files #205

Merged
merged 24 commits into from
Mar 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
9b36354
feat: add first version of PbfTagLoader
RaczeQ Mar 16, 2023
c6645f2
fix: apply refurb suggestion
RaczeQ Mar 16, 2023
971cdf2
feat: improve buffering and pbf downloading
RaczeQ Mar 17, 2023
a6f1b83
chore: modify pdm file
RaczeQ Mar 17, 2023
f4c992a
ci: added new nvidia libraries licenses to ignore
RaczeQ Mar 17, 2023
03aee70
chore: refactor code and add docstrings
RaczeQ Mar 17, 2023
2e9bdeb
feat(OSMPbfLoader): added example notebook
RaczeQ Mar 17, 2023
cb475dc
chore: modified modules docstrings
RaczeQ Mar 17, 2023
cf3eaaf
feat: modify pbf loader examples
RaczeQ Mar 18, 2023
841bf1c
feat: modify OSMPbfLoader geometries parsing
RaczeQ Mar 18, 2023
5aefb34
chore: changed example plots
RaczeQ Mar 18, 2023
66239f3
chore: change protomaps progress bars
RaczeQ Mar 18, 2023
efa5c73
chore: add prettymaps contribution
RaczeQ Mar 18, 2023
11ba806
chore: change directories names
RaczeQ Mar 19, 2023
0775eef
chore: add tests for OSMPbfLoader
RaczeQ Mar 19, 2023
9b3204f
fix: changed geometry hash calculation
RaczeQ Mar 19, 2023
b61f412
feat: added user agent header with library info
RaczeQ Mar 19, 2023
9b18518
chore: formatted notes in osm loaders
RaczeQ Mar 20, 2023
3d3098e
chore: merge remote-tracking branch 'origin/main' into 52-add-osmload…
RaczeQ Mar 20, 2023
97ef594
chore: refactor utils module
RaczeQ Mar 20, 2023
ab558fd
chore: update srai/loaders/osm_loaders/filters/osm_tags_type.py
RaczeQ Mar 20, 2023
f7cce35
chore: update srai/loaders/osm_loaders/osm_pbf_loader.py
RaczeQ Mar 20, 2023
ce9b032
chore: applied CR suggestions
RaczeQ Mar 21, 2023
a099b56
chore: applied CR suggestions
RaczeQ Mar 21, 2023
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
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -142,4 +142,7 @@ requirements.txt
cache/

# pytorch lightning
lightning_logs/
lightning_logs/

# files_cache
files/
9 changes: 7 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Changelog

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/),
Expand All @@ -7,15 +8,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased] - 2022-MM-DD

### Added

- GTFS Loader from gtfs2vec paper
- GTFS2Vec Model from gtfs2vec paper
- GTFS2Vec Embedder using gtfs2vec model
- OSMTagLoader
- OSMOnlineLoader
- OSMPbfLoader
- Neighbourhood
- H3Neighbourhood
- AdjacencyNeighbourhood

### Changed

- Change embedders and joiners interface to have `.transform` method

### Deprecated
Expand All @@ -29,6 +33,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [0.0.1] - 2022-11-23

### Added

- PDM as a dependency management tool
- black, flake8, isort, mypy, pytest-cov
- pre-commit configuration
Expand All @@ -42,5 +47,5 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Intersection Joiner
- Geoparquet Loader

[Unreleased]: https://github.com/srai-lab/srai/compare/0.0.1...HEAD
[unreleased]: https://github.com/srai-lab/srai/compare/0.0.1...HEAD
[0.0.1]: https://github.com/srai-lab/srai/compare/687500b...0.0.1
6 changes: 3 additions & 3 deletions examples/embedders/count_embedder.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
"source": [
"from shapely import geometry\n",
"import geopandas as gpd\n",
"from srai.utils.constants import WGS84_CRS\n",
"from srai.loaders.osm_tag_loader import OSMTagLoader\n",
"from srai.constants import WGS84_CRS\n",
"from srai.loaders.osm_loaders import OSMOnlineLoader\n",
"from srai.regionizers import H3Regionizer\n",
"from srai.joiners import IntersectionJoiner\n",
"from srai.embedders import CountEmbedder"
Expand Down Expand Up @@ -93,7 +93,7 @@
"metadata": {},
"outputs": [],
"source": [
"loader = OSMTagLoader()\n",
"loader = OSMOnlineLoader()\n",
"tags = {\n",
" \"leisure\": [\"playground\", \"adult_gaming_centre\"],\n",
" \"amenity\": \"pub\",\n",
Expand Down
2 changes: 2 additions & 0 deletions examples/loaders/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ Examples illustrating the usage of every Loader.

- [GeoparquetLoader](geoparquet_loader.ipynb)
- [GTFSLoader](gtfs_loader.ipynb)
- [OSMOnlineLoader](osm_online_loader.ipynb)
- [OSMPbfLoader](osm_pbf_loader.ipynb)
2 changes: 0 additions & 2 deletions examples/loaders/files/.gitignore

This file was deleted.

10 changes: 6 additions & 4 deletions examples/loaders/geoparquet_loader.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"metadata": {},
"outputs": [],
"source": [
"base_gdf = gpql.load(file_path=\"files/example.parquet\")\n",
"base_gdf = gpql.load(file_path=\"example_files/example.parquet\")\n",
"base_gdf"
]
},
Expand All @@ -55,7 +55,7 @@
"metadata": {},
"outputs": [],
"source": [
"indexed_gdf = gpql.load(file_path=\"files/example.parquet\", index_column=\"name\")\n",
"indexed_gdf = gpql.load(file_path=\"example_files/example.parquet\", index_column=\"name\")\n",
"indexed_gdf"
]
},
Expand All @@ -65,7 +65,9 @@
"metadata": {},
"outputs": [],
"source": [
"limited_gdf = gpql.load(file_path=\"files/example.parquet\", columns=[\"continent\", \"name\", \"pop_est\"])\n",
"limited_gdf = gpql.load(\n",
" file_path=\"example_files/example.parquet\", columns=[\"continent\", \"name\", \"pop_est\"]\n",
")\n",
"limited_gdf"
]
},
Expand All @@ -79,7 +81,7 @@
"bbox = box(minx=-106.645646, maxx=-93.508292, miny=25.837377, maxy=36.500704)\n",
"bbox_gdf = gpd.GeoDataFrame({\"geometry\": [bbox]}, crs=\"EPSG:4326\")\n",
"\n",
"cut_gdf = gpql.load(file_path=\"files/example.parquet\", area=bbox_gdf)\n",
"cut_gdf = gpql.load(file_path=\"example_files/example.parquet\", area=bbox_gdf)\n",
"cut_gdf"
]
},
Expand Down
6 changes: 3 additions & 3 deletions examples/loaders/gtfs_loader.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
"import geopandas as gpd\n",
"import numpy as np\n",
"from shapely.geometry import Point\n",
"from srai.utils.constants import WGS84_CRS\n",
"from utils import download"
"from srai.constants import WGS84_CRS\n",
"from srai.utils import download_file"
]
},
{
Expand All @@ -46,7 +46,7 @@
"wroclaw_gtfs = Path().resolve() / \"files\" / \"example.zip\"\n",
"gtfs_url = \"https://transitfeeds.com/p/mpk-wroc-aw/663/20221221/download\"\n",
"\n",
"download(gtfs_url, wroclaw_gtfs.as_posix())"
"download_file(gtfs_url, wroclaw_gtfs.as_posix())"
]
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# OSM Tag Loader"
"# OSM Online Loader"
]
},
{
Expand All @@ -14,10 +14,10 @@
"metadata": {},
"outputs": [],
"source": [
"from srai.loaders.osm_tag_loader.filters.popular import get_popular_tags\n",
"from srai.loaders.osm_tag_loader.filters import HEX2VEC_FILTER\n",
"from srai.loaders.osm_tag_loader import OSMTagLoader\n",
"from srai.utils.geocode import geocode_to_region_gdf\n",
"from srai.loaders.osm_loaders.filters.popular import get_popular_tags\n",
"from srai.loaders.osm_loaders.filters import HEX2VEC_FILTER\n",
"from srai.loaders.osm_loaders import OSMOnlineLoader\n",
"from srai.utils import geocode_to_region_gdf\n",
"from functional import seq"
]
},
Expand Down Expand Up @@ -95,7 +95,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Using OSMTagLoader to download data for a specific area"
"## Using OSMOnlineLoader to download data for a specific area"
]
},
{
Expand All @@ -112,7 +112,7 @@
"metadata": {},
"outputs": [],
"source": [
"loader = OSMTagLoader()\n",
"loader = OSMOnlineLoader()\n",
"parks_filter = {\"leisure\": \"park\"}\n",
"wroclaw_gdf = geocode_to_region_gdf(\"Wrocław, Poland\")\n",
"parks_gdf = loader.load(wroclaw_gdf, parks_filter)\n",
Expand Down
Loading