PBF File Reader¶
PBFFileReader
can really quickly parse full OSM extract in the form of *.osm.pbf
file.
It uses DuckDB
with spatial
extension to convert pbf
files into geoparquet
files without GDAL dependency.
Reader can filter objects by geometry and by OSM tags with option to split tags into columns or keep it as a single dictionary.
Caching strategy is implemented to reduce computations, but it can be overriden using ignore_cache
parameter.
Download all buildings in Reykjavík, Iceland¶
Filtering the data with geometry and by tags, with tags in exploded form
import urllib.request
from quackosm import PbfFileReader, geocode_to_geometry
iceland_pbf_url = "https://download.geofabrik.de/europe/iceland-latest.osm.pbf"
iceland_pbf_file = "iceland.osm.pbf"
urllib.request.urlretrieve(iceland_pbf_url, iceland_pbf_file)
('iceland.osm.pbf', <http.client.HTTPMessage at 0x7fb803e88740>)
reykjavik_geometry = geocode_to_geometry("Reykjavík, IS")
reykjavik_geometry
To filter out buildings, we will utilize format used also in the osmnx
library: a dictionary with keys representing tag keys and values that could be a bool, string or a list of string.
By default, QuackOSM
will return only the tags that are present in the passed filter.
In this example we will select all the buildings using { "building": True }
filter and only building
tag values will be present in the result.
reader = PbfFileReader(
geometry_filter=reykjavik_geometry, tags_filter={"building": True}
)
reykjavik_buildings_gpq = reader.convert_pbf_to_parquet("iceland.osm.pbf")
reykjavik_buildings_gpq
Finished operation in 0:00:18
PosixPath('files/iceland_ae99e3d9_4e8a6f65_exploded_sorted.parquet')
Read those features using DuckDB¶
import duckdb
connection = duckdb.connect()
connection.load_extension("parquet")
connection.load_extension("spatial")
features_relation = connection.read_parquet(str(reykjavik_buildings_gpq))
features_relation
┌────────────────┬────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┬──────────────┐ │ feature_id │ geometry │ building │ │ varchar │ geometry │ varchar │ ├────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┼──────────────┤ │ way/61934038 │ POLYGON ((-21.8437438 64.1084884, -21.8437503 64.1082447, -21.8437548 64.1080761, -21.844211 64.1080784, -21.8442 64.1084907, -21.8437438 64.1084884)) │ yes │ │ way/61934018 │ POLYGON ((-21.8431866 64.1079564, -21.8431225 64.1079561, -21.843123 64.1079396, -21.8431273 64.1077785, -21.8431962 64.1077788, -21.843197 64.1077511, -21.843708 64.1077537, -21.8437072 64.1077839, -21.843764 64.1077841, -21.8437592 64.1079616, -21.8436976 64.1079613, -21.8436962 64.1080122, -21.8431852 64.1080096, -21.8431866 64.1079564)) │ apartments │ │ way/61933932 │ POLYGON ((-21.8434848 64.1070313, -21.8434268 64.1070543, -21.843394 64.1069969, -21.8432922 64.1070146, -21.843207 64.1070404, -21.8433233 64.1070904, -21.8432325 64.1070969, -21.8432383 64.1071307, -21.843187 64.1071575, -21.8432326 64.1071819, -21.8432242 64.1072204, -21.843299 64.1072354, -21.8433326 64.1072691, -21.8433761 64.107268, -21.843322 64.1073354, -21.8433933 64.1073462, -21.8434693 64.107349, -21.8435612 64.1073458, -21.8436249 64.1073376, -21.8435791 64.1072684, -21.8436211 64.1072707, -21.8436537 64.1072371, -21.8437317 64.1072233, -21.8437179 64.1071874, -21.8437759 64.1071601, -21.8437236 64.1071316, -21.8437386 64.1070967, -21.8436633 64.107085, -21.8436326 64.1070471, -21.8435497 64.1070556, -21.8434848 64.1070313)) │ church │ │ way/61934167 │ POLYGON ((-21.8443402 64.108232, -21.8443443 64.1080791, -21.8443535 64.1077336, -21.8443541 64.1077086, -21.8448455 64.1077111, -21.8448425 64.1078236, -21.8449022 64.1078239, -21.844893 64.1081703, -21.8447929 64.1081698, -21.8447912 64.1082342, -21.8443402 64.108232)) │ yes │ │ way/1346502222 │ POLYGON ((-21.8523431 64.1054147, -21.8520855 64.1051045, -21.8482221 64.1057163, -21.8484909 64.1060401, -21.8491877 64.1059297, -21.8491363 64.1058678, -21.8513297 64.1055207, -21.8513697 64.1055689, -21.8523431 64.1054147)) │ construction │ │ way/849242393 │ POLYGON ((-21.8477126 64.1052314, -21.8477865 64.1053217, -21.8480253 64.1052844, -21.848183 64.105477, -21.8479411 64.1055148, -21.8480191 64.10561, -21.8484656 64.1055403, -21.848156 64.1051621, -21.8477126 64.1052314)) │ yes │ │ way/204102373 │ POLYGON ((-21.8451786 64.1055617, -21.8456047 64.1056787, -21.84601 64.10579, -21.8459173 64.1058544, -21.8459857 64.1058727, -21.846112 64.1057827, -21.8461856 64.1058025, -21.846246 64.1057594, -21.8461874 64.1057437, -21.8463012 64.1056626, -21.8462285 64.1056428, -21.8461376 64.1057066, -21.8457298 64.1055958, -21.8457048 64.1055488, -21.8455401 64.1055041, -21.8454232 64.105516, -21.8452938 64.1054809, -21.8451786 64.1055617)) │ yes │ │ way/95141704 │ POLYGON ((-21.846527 64.1057239, -21.8463012 64.1056626, -21.8462285 64.1056428, -21.8460204 64.1055863, -21.8461907 64.1054668, -21.8466973 64.1056044, -21.846527 64.1057239)) │ residential │ │ way/95141705 │ POLYGON ((-21.846062 64.1060629, -21.8455547 64.1059271, -21.8457279 64.1058037, -21.8459173 64.1058544, -21.8459857 64.1058727, -21.8462352 64.1059395, -21.846062 64.1060629)) │ residential │ │ way/923188606 │ POLYGON ((-21.8471423 64.1058071, -21.847081 64.1058173, -21.8470434 64.1057739, -21.8471047 64.1057638, -21.8471423 64.1058071)) │ yes │ │ · │ · │ · │ │ · │ · │ · │ │ · │ · │ · │ │ way/107499255 │ POLYGON ((-21.7752934 64.1461881, -21.7752114 64.1462968, -21.7752789 64.1463065, -21.7752873 64.1462954, -21.775333 64.146302, -21.7754066 64.1462044, -21.7752934 64.1461881)) │ residential │ │ way/107499264 │ POLYGON ((-21.7752934 64.1461881, -21.7751811 64.146172, -21.7751072 64.1462698, -21.7751482 64.1462757, -21.77514 64.1462865, -21.7752114 64.1462968, -21.7752934 64.1461881)) │ residential │ │ way/107499296 │ POLYGON ((-21.7761242 64.1464504, -21.7757389 64.1464324, -21.7757639 64.1463304, -21.7758411 64.146334, -21.7758569 64.1462695, -21.7760925 64.1462805, -21.7760762 64.1463471, -21.7761487 64.1463505, -21.7761242 64.1464504)) │ residential │ │ way/107499263 │ POLYGON ((-21.7764388 64.1460403, -21.7760522 64.1460214, -21.7760782 64.1459203, -21.7761569 64.1459241, -21.7761739 64.1458582, -21.7764086 64.1458697, -21.7763911 64.1459377, -21.7764643 64.1459413, -21.7764388 64.1460403)) │ residential │ │ way/107499211 │ POLYGON ((-21.777345 64.1460877, -21.7769605 64.146069, -21.7769871 64.1459652, -21.7770648 64.145969, -21.7770811 64.1459053, -21.7773149 64.1459167, -21.7772981 64.1459821, -21.7773712 64.1459856, -21.777345 64.1460877)) │ residential │ │ way/107499191 │ POLYGON ((-21.7757411 64.1455954, -21.7756575 64.1457061, -21.7757288 64.1457164, -21.7757386 64.1457035, -21.7757862 64.1457103, -21.7758601 64.1456125, -21.7757411 64.1455954)) │ residential │ │ way/107499218 │ POLYGON ((-21.7755203 64.1458898, -21.7754103 64.145874, -21.7753376 64.1459708, -21.7753777 64.1459765, -21.7753691 64.145988, -21.7754389 64.145998, -21.7755203 64.1458898)) │ residential │ │ way/107499226 │ POLYGON ((-21.7755203 64.1458898, -21.7754389 64.145998, -21.7755101 64.1460082, -21.7755187 64.1459968, -21.7755643 64.1460033, -21.7756371 64.1459065, -21.7755203 64.1458898)) │ residential │ │ way/107499289 │ POLYGON ((-21.7754103 64.145874, -21.7753035 64.1458588, -21.7752224 64.1459667, -21.7752884 64.1459761, -21.7752968 64.145965, -21.7753376 64.1459708, -21.7754103 64.145874)) │ residential │ │ way/107499224 │ POLYGON ((-21.7753035 64.1458588, -21.7751945 64.1458432, -21.7751209 64.1459411, -21.7751606 64.1459468, -21.7751531 64.1459568, -21.7752224 64.1459667, -21.7753035 64.1458588)) │ residential │ ├────────────────┴────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┴──────────────┤ │ ? rows (>9999 rows, 20 shown) 3 columns │ └────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
Count all buildings¶
features_relation.count("feature_id")
┌───────────────────┐ │ count(feature_id) │ │ int64 │ ├───────────────────┤ │ 25392 │ └───────────────────┘
Keeping all the tags while filtering the data¶
To keep all of the tags present in the source data, we can use keep_all_tags
parameter. That way we will still return only buildings, but with all of the tags attached.
By default, all of those tags will be kept in a single column as a dict
.
reader.convert_pbf_to_geodataframe("iceland.osm.pbf", keep_all_tags=True)
Finished operation in 0:00:17
tags | geometry | |
---|---|---|
feature_id | ||
way/61934038 | {'addr:housenumber': '10', 'addr:postcode': '1... | POLYGON ((-21.84374 64.10849, -21.84375 64.108... |
way/61934018 | {'addr:city': 'Reykjavík', 'addr:housenumber':... | POLYGON ((-21.84319 64.10796, -21.84312 64.107... |
way/61933932 | {'addr:housenumber': '5', 'addr:postcode': '10... | POLYGON ((-21.84348 64.10703, -21.84343 64.107... |
way/61934167 | {'addr:housenumber': '8', 'addr:postcode': '10... | POLYGON ((-21.84434 64.10823, -21.84434 64.108... |
way/1346502222 | {'addr:city': 'Reykjavík', 'addr:housenumber':... | POLYGON ((-21.85234 64.10541, -21.85209 64.105... |
... | ... | ... |
way/222355490 | {'addr:housenumber': '6', 'addr:postcode': '11... | POLYGON ((-21.69511 64.11597, -21.69516 64.115... |
way/365759197 | {'building': 'industrial'} | POLYGON ((-21.70156 64.1055, -21.70186 64.1051... |
relation/13506468 | {'addr:city': 'Reykjavík', 'addr:housenumber':... | POLYGON ((-21.69638 64.09985, -21.69636 64.099... |
way/992249961 | {'building': 'yes'} | POLYGON ((-21.6986 64.09975, -21.69855 64.0997... |
way/570226126 | {'building': 'yes'} | POLYGON ((-21.70041 64.08481, -21.70032 64.084... |
25392 rows × 2 columns
Download main roads for Estonia¶
Filtering the data only by tags, with tags in exploded form
highways_filter = {
"highway": [
"motorway",
"trunk",
"primary",
"secondary",
"tertiary",
]
}
estonia_pbf_url = "http://download.geofabrik.de/europe/estonia-latest.osm.pbf"
estonia_pbf_file = "estonia.osm.pbf"
urllib.request.urlretrieve(estonia_pbf_url, estonia_pbf_file)
reader = PbfFileReader(geometry_filter=None, tags_filter=highways_filter)
estonia_features_gpq = reader.convert_pbf_to_parquet(estonia_pbf_file)
estonia_features_gpq
Finished operation in 0:00:19
PosixPath('files/estonia_87e7b741_noclip_exploded_sorted.parquet')
features_relation = connection.read_parquet(str(estonia_features_gpq))
features_relation
┌────────────────┬───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┬──────────┐ │ feature_id │ geometry │ highway │ │ varchar │ geometry │ varchar │ ├────────────────┼───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┼──────────┤ │ way/1018216517 │ LINESTRING (22.0563349 57.9115746, 22.0565881 57.911771, 22.0567573 57.9119305, 22.0568909 57.912108, 22.0569823 57.9122961, 22.057069 57.9125329, 22.0571383 57.9127075) │ tertiary │ │ way/441801965 │ LINESTRING (22.055825 57.9111269, 22.0560882 57.9113742, 22.0563349 57.9115746) │ tertiary │ │ way/37439072 │ LINESTRING (22.0571383 57.9127075, 22.0571903 57.9127901, 22.0573036 57.9128767, 22.0573909 57.9129283, 22.0575834 57.9129985, 22.0576021 57.9130034, 22.0579829 57.9131031, 22.0581652 57.9131651, 22.0583127 57.913228, 22.0584328 57.9132951, 22.0585628 57.9133852, 22.0586936 57.9134988, 22.058829 57.9136461, 22.0594326 57.9143824, 22.0596083 57.9145685, 22.0597846 57.9147444, 22.060021 57.9149467, 22.0606738 57.9154739, 22.0613254 57.9160024, 22.06168 57.9162791, 22.0619472 57.9164677, 22.0621751 57.9166234, 22.0626801 57.9169592, 22.0630516 57.9171963, 22.0632575 57.9173115, 22.0634442 57.9174006, 22.0636074 57.9174747, 22.0637146 57.917547, 22.0638036 57.9176209, 22.0640832 57.9178738) │ tertiary │ │ way/1018216516 │ LINESTRING (22.0640832 57.9178738, 22.0642168 57.9179896, 22.0642584 57.918064, 22.0642581 57.9181382) │ tertiary │ │ way/232265919 │ LINESTRING (22.0409996 58.0039353, 22.0388314 58.002661, 22.03839 58.0025194, 22.0380646 58.0024242, 22.0376184 58.0022958, 22.0370582 58.0021423, 22.0363056 58.0019396, 22.0344895 58.0014445, 22.0334132 58.0011464, 22.031798 58.0007169, 22.0312669 58.0005554, 22.0308003 58.0003958, 22.0299982 58.0000671, 22.0293673 57.9997562, 22.0255445 57.9975239, 22.0235683 57.9963199, 22.0216864 57.9951733, 22.019945 57.9941124, 22.0190591 57.9934761, 22.0189449 57.993394, 22.0185402 57.9927809, 22.0184637 57.9923089, 22.0184254 57.9918108, 22.0185665 57.9912965, 22.0193382 57.9896141, 22.0197497 57.9886068, 22.0203264 57.9873089, 22.0207424 57.986355, 22.0209716 57.9857848, 22.0210919 57.9854853, 22.0213131 57.9849392, 22.0215284 57.9844135, 22.0216545 57.9839407, 22.0216902 57.9836398, 22.0217102 57.9833145, 22.0215934 57.982903, 22.021419 57.9825155, 22.0211337 57.9819858, 22.0208339 57.9816209, 22.0205326 57.9813067, 22.0198611 57.9808164, 22.0189558 57.9802367, 22.0181816 57.9797606, 22.0169012 57.9789891, 22.0144007 57.9774724, 22.0126276 57.9764101, 22.0114743 57.975706, 22.0107859 57.9752858, 22.0071663 57.9731103, 22.0061964 57.9724639, 22.0052121 57.9717478, 22.0039716 57.970712, 22.0029867 57.9697428, 22.00269 57.9694162, 22.0019228 57.968535, 22.0013785 57.9677904, 22.0003182 57.9662021, 21.9992996 57.9646586, 21.9972166 57.9615807, 21.9971443 57.9614702, 21.9967701 57.9608983, 21.996616 57.9604841, 21.9964811 57.9599436, 21.9964489 57.9593717, 21.9965829 57.9584759, 21.9967887 57.9575496, 21.9971487 57.9556953, 21.9974206 57.9543359, 21.997672 57.9530652, 21.9976949 57.9529393, 21.997965 57.9516116, 21.9980774 57.9511991, 21.9982022 57.9509179, 21.9983111 57.9507133, 21.9986802 57.9501513, 21.9990458 57.9496884, 21.9995387 57.9492148, 22.0000886 57.9487813, 22.0002683 57.9486511, 22.0004491 57.9485276, 22.0008378 57.9482893, 22.0016256 57.9478062, 22.0039493 57.946387, 22.0067603 57.9446678, 22.0080223 57.9438992, 22.0081881 57.9437989, 22.0106623 57.9422877, 22.0117012 57.9416498, 22.0123896 57.941114, 22.0128118 57.9407148, 22.0133024 57.9401891, 22.0134488 57.9399937, 22.0140052 57.9391042, 22.0145747 57.9381741, 22.0149037 57.9376662, 22.0152858 57.9371623, 22.0164393 57.9358291, 22.0173204 57.9348554, 22.0181691 57.9339626, 22.0184151 57.9338105, 22.0188136 57.9336245, 22.0251493 57.9310279, 22.0348016 57.9271172, 22.0375506 57.926033, 22.0445412 57.9237122, 22.0468228 57.9229301, 22.0473732 57.9227291, 22.0476643 57.9225905, 22.0482686 57.9222757, 22.0491394 57.9217129, 22.0506239 57.9207264, 22.0512772 57.9202941, 22.051932 57.91989, 22.0524278 57.9196645, 22.052747 57.919569, 22.0530308 57.9195005, 22.0534041 57.9194237, 22.0540667 57.9193325, 22.0574948 57.9189141, 22.0596265 57.9186637, 22.0618148 57.9183929, 22.0636563 57.9181602, 22.0639902 57.918131, 22.0642581 57.9181382, 22.0644605 57.9181695, 22.0647002 57.9182452, 22.0649041 57.9183419, 22.0662254 57.9190668, 22.0667118 57.9193563, 22.067059 57.9195838, 22.0673697 57.9198141, 22.0676331 57.9200253, 22.0679073 57.9202593, 22.0681937 57.9205324, 22.0687993 57.9210981, 22.069128 57.9214281, 22.0704011 57.9228595, 22.0710745 57.9235712, 22.0717436 57.9242615, 22.0723043 57.9247631, 22.0728413 57.9251791, 22.0733455 57.9255487, 22.0736327 57.9257744, 22.0738081 57.9258917, 22.0740418 57.926021, 22.0743881 57.9261976, 22.074814 57.9263984, 22.0753661 57.9266451, 22.0757039 57.9267793, 22.0761404 57.9269525, 22.0769401 57.927235, 22.0789279 57.9278726, 22.0807069 57.9283837, 22.082883 57.928978, 22.0838908 57.9292754, 22.0847777 57.9295613, 22.0853585 57.929765, 22.0865895 57.9302597, 22.0874274 57.9306336, 22.0920971 57.9330818, 22.0952889 57.9347543, 22.097774 57.9359314, 22.1000961 57.9370645, 22.1030526 57.9387145, 22.1039535 57.9391836, 22.1049281 57.9396676, 22.1061235 57.9402157, 22.1068671 57.9405925, 22.107055 57.9407084, 22.1071949 57.9408593, 22.1076188 57.9415401, 22.1078304 57.941831, 22.1081511 57.9421122, 22.1086647 57.9424304, 22.1093062 57.9427187, 22.1114706 57.9434859, 22.1122651 57.9438023, 22.1152236 57.9453406, 22.1155635 57.9455581, 22.1158115 57.945766, 22.1160467 57.9460158, 22.1187927 57.9495541, 22.1191505 57.9500351, 22.1195952 57.9505917, 22.1198863 57.9508971, 22.12105 57.9520537, 22.121246 57.9523306, 22.1213243 57.9524814, 22.1213918 57.9528157, 22.1213298 57.9532003, 22.1212331 57.9537161, 22.1211679 57.954094, 22.1211802 57.9542294, 22.1212168 57.9543797, 22.1213226 57.954477, 22.1219175 57.9548877, 22.1220815 57.9550373, 22.122546 57.9558138, 22.1239156 57.957798, 22.1241603 57.9582011, 22.1248062 57.9591621, 22.1257003 57.9601034, 22.12679 57.9611765, 22.1273795 57.9620948, 22.1280326 57.9631733, 22.1283243 57.9638429, 22.128603 57.9645727, 22.128952 57.965223, 22.1319977 57.9684531, 22.1334987 57.9698068, 22.1346931 57.9711443, 22.1349226 57.9715106) │ tertiary │ │ way/1018220952 │ LINESTRING (22.1068474 57.9623483, 22.1065086 57.962407, 22.1036122 57.9631158, 22.1012661 57.9639724, 22.0999695 57.9646673, 22.0888238 57.970641, 22.0884304 57.9708519, 22.08696 57.9716403, 22.0843338 57.9730484, 22.0816274 57.9742212) │ tertiary │ │ way/1018220953 │ LINESTRING (22.0608019 57.978236, 22.0535175 57.9800692) │ tertiary │ │ way/1018220951 │ LINESTRING (22.0622446 57.9779054, 22.0608019 57.978236) │ tertiary │ │ way/4937123 │ LINESTRING (22.0792412 57.975065, 22.0777345 57.9755978, 22.0765658 57.9761355, 22.0755268 57.9765237, 22.0749313 57.9767099, 22.0742608 57.9768686, 22.0735309 57.97699, 22.0709656 57.9773805, 22.0701591 57.9774945, 22.0693971 57.9775859, 22.0690844 57.9776128, 22.0687346 57.9776384, 22.0684389 57.9776509, 22.0677736 57.977668, 22.063527 57.9777223, 22.0632252 57.9777654, 22.0622446 57.9779054) │ tertiary │ │ way/1018220950 │ LINESTRING (22.0816274 57.9742212, 22.0792412 57.975065) │ tertiary │ │ · │ · │ · │ │ · │ · │ · │ │ · │ · │ · │ │ way/1029244826 │ LINESTRING (24.7265 59.1697007, 24.7270543 59.1696799, 24.7276123 59.1696525, 24.7279424 59.169665, 24.7281843 59.1696922) │ tertiary │ │ way/1318480946 │ LINESTRING (24.7261717 59.1696893, 24.7263462 59.169696, 24.7265 59.1697007) │ tertiary │ │ way/205945160 │ LINESTRING (24.672583 59.1623789, 24.6746104 59.1626556, 24.6767006 59.1629502, 24.6794993 59.1633447, 24.6835111 59.1639036, 24.687555 59.1644433, 24.6892726 59.164685, 24.6917634 59.1650217, 24.6969623 59.1657412, 24.6991169 59.1661149, 24.7006747 59.1664374, 24.7012407 59.1665714, 24.7020272 59.1667759, 24.7023271 59.1668597, 24.7034854 59.1671833, 24.7038155 59.1672638, 24.7059564 59.1677729, 24.7069657 59.167977, 24.7070908 59.1680006, 24.7074328 59.1680651, 24.7094987 59.1683682, 24.7100518 59.1684386, 24.7119671 59.1686325, 24.7124611 59.1686759, 24.7146632 59.168869, 24.7160885 59.1689857, 24.7193932 59.1692137, 24.7217885 59.1693952, 24.7219172 59.169403, 24.724264 59.1695866, 24.7251659 59.1696404, 24.7257551 59.1696789, 24.7261717 59.1696893) │ tertiary │ │ way/645018261 │ LINESTRING (24.7093032 59.156516, 24.7091579 59.1570968, 24.7088547 59.158278, 24.7087863 59.1588322, 24.7084943 59.1598237, 24.7084532 59.1601901, 24.7079176 59.1622391, 24.7077734 59.162961, 24.7077373 59.1633866, 24.7075391 59.1640066, 24.7072868 59.1650153, 24.7072868 59.1654503, 24.7072537 59.1656713, 24.7072147 59.1659314, 24.7072147 59.1665421, 24.7070952 59.1671543, 24.707018 59.1676602, 24.7069657 59.167977) │ tertiary │ │ way/979525407 │ LINESTRING (24.7100753 59.1552191, 24.7099703 59.155252, 24.7097571 59.1553387, 24.7095546 59.1554695, 24.7094847 59.1556396, 24.7093032 59.156516) │ tertiary │ │ way/1029010398 │ LINESTRING (24.6641406 59.1607984, 24.6660199 59.1611873, 24.6688824 59.1617915, 24.6693748 59.1618831, 24.6700884 59.1620175, 24.6708917 59.1621381, 24.672583 59.1623789) │ tertiary │ │ way/1032937378 │ LINESTRING (24.6681709 59.2028611, 24.6685276 59.2023154, 24.6686335 59.2021512, 24.6688044 59.2018073, 24.6688749 59.2016672, 24.6689358 59.2014988, 24.6690478 59.2010322, 24.6690895 59.2006919, 24.6690974 59.2004212, 24.6690723 59.200158, 24.6689256 59.199664, 24.6686611 59.1992188, 24.6685991 59.1991573, 24.6682953 59.1988563, 24.6643349 59.1955668, 24.6636053 59.1948802, 24.6633479 59.1945368, 24.6631547 59.1941935, 24.662871 59.1934561) │ tertiary │ │ way/1029007288 │ LINESTRING (24.6668621 59.2045667, 24.6674463 59.203871, 24.6681709 59.2028611) │ tertiary │ │ way/221578033 │ LINESTRING (24.6840237 59.2097778, 24.6850478 59.2088526, 24.6864898 59.207522, 24.6875378 59.2065333, 24.6877378 59.2062956, 24.6879003 59.2059816, 24.6880495 59.2053159, 24.6882825 59.2044727, 24.6885607 59.2039255, 24.6893973 59.2029624, 24.6908403 59.2017885, 24.6949819 59.1985157, 24.6963984 59.1973661, 24.697758 59.1961074, 24.6984688 59.1953948, 24.6994676 59.194563, 24.699502 59.1945343, 24.7001324 59.1940877, 24.7004705 59.1938481, 24.7007439 59.1936784, 24.7010495 59.1935368, 24.7013689 59.1934042, 24.7018792 59.1932213, 24.7025765 59.1930312, 24.7031968 59.1928796, 24.7039522 59.1926757, 24.7042514 59.1925682, 24.704568 59.1924136, 24.7055367 59.1918321, 24.7058853 59.1916229, 24.7080317 59.1903153, 24.7087004 59.1899028, 24.710045 59.1889671, 24.7112278 59.1880717, 24.7119232 59.1874149, 24.7131477 59.1862956, 24.7152079 59.1845118, 24.7157593 59.184117, 24.7168475 59.1833655) │ tertiary │ │ way/1029007291 │ LINESTRING (24.6809074 59.2126475, 24.6821129 59.2115386) │ tertiary │ ├────────────────┴───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┴──────────┤ │ ? rows (>9999 rows, 20 shown) 3 columns │ └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
Count loaded roads¶
features_relation.count("feature_id")
┌───────────────────┐ │ count(feature_id) │ │ int64 │ ├───────────────────┤ │ 26981 │ └───────────────────┘
length_in_meters = (
features_relation.project(
"ST_Length(ST_Transform(geometry, 'EPSG:4326', 'EPSG:3301')) AS road_length"
)
.sum("road_length")
.fetchone()[0]
)
length_in_km = length_in_meters / 1000
length_in_km
29525.445102167967
Plot the roads using GeoPandas¶
With fast loading of geoparquet files using geoarrow.pyarrow
library.
import geoarrow.pyarrow as ga
from geoarrow.pyarrow import io
from quackosm._constants import GEOMETRY_COLUMN
parquet_table = io.read_geoparquet_table(estonia_features_gpq)
ga.to_geopandas(parquet_table.column(GEOMETRY_COLUMN)).plot()
<Axes: >
Download all data for Liechtenstein¶
Without filtering, with tags in a compact form
liechtenstein_pbf_url = "https://download.geofabrik.de/europe/liechtenstein-latest.osm.pbf"
liechtenstein_pbf_file = "liechtenstein.osm.pbf"
urllib.request.urlretrieve(liechtenstein_pbf_url, liechtenstein_pbf_file)
# Here explode_tags is set to False explicitly,
# but it would set automatically when not filtering the data
reader = PbfFileReader(geometry_filter=None, tags_filter=None)
liechtenstein_features_gpq = reader.convert_pbf_to_parquet(
liechtenstein_pbf_file, explode_tags=False
)
liechtenstein_features_gpq
Finished operation in 0:00:06
PosixPath('files/liechtenstein_nofilter_noclip_compact_sorted.parquet')
features_relation = connection.read_parquet(str(liechtenstein_features_gpq))
features_relation
┌─────────────────┬─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┬───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ │ feature_id │ tags │ geometry │ │ varchar │ map(varchar, varchar) │ geometry │ ├─────────────────┼─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┼───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤ │ node/540308211 │ {power=tower} │ POINT (9.5372399 46.9862797) │ │ node/1338490716 │ {power=tower} │ POINT (9.5342839 46.9887559) │ │ node/540308206 │ {power=tower} │ POINT (9.5313353 46.9912103) │ │ node/540308180 │ {power=tower} │ POINT (9.5285455 46.9936492) │ │ node/540308170 │ {power=tower} │ POINT (9.5257615 46.9960867) │ │ node/540308159 │ {power=tower} │ POINT (9.5231821 46.998349) │ │ way/160527579 │ {highway=path, surface=gravel} │ LINESTRING (9.4763856 47.0521369, 9.4764306 47.0519574, 9.476491 47.0518671, 9.4766172 47.0517149, 9.476662 47.0516592, 9.4766745 47.0515936, 9.4767745 47.0514237, 9.4768773 47.0512946, 9.4769524 47.0511758, 9.4770544 47.0510716, 9.4770946 47.050993, 9.4772689 47.0507445, 9.4773317 47.0505664, 9.4774119 47.0503482, 9.4774255 47.0502526, 9.4774889 47.0501908, 9.4775274 47.0500558, 9.477582 47.0499795, 9.4776337 47.0498801, 9.4776686 47.0498161, 9.4778721 47.0497533) │ │ way/122990817 │ {admin_level=4, boundary=administrative} │ LINESTRING (9.4772452 47.049055, 9.4757865 47.0517524) │ │ node/1725816418 │ {barrier=bollard} │ POINT (9.4763856 47.0521369) │ │ way/1214145501 │ {'cycleway:both'=no, highway=unclassified, lane_markings=no, name=Rheindamm, smoothness=excellent, surface=asphalt, width=4} │ LINESTRING (9.476461 47.0524842, 9.4766379 47.0521002) │ │ · │ · │ · │ │ · │ · │ · │ │ · │ · │ · │ │ way/477560748 │ {landuse=grass} │ POLYGON ((9.5263478 47.1196992, 9.5259239 47.1196217, 9.5258332 47.1199101, 9.5258242 47.1200278, 9.525789 47.1204885, 9.5258716 47.1204976, 9.526412 47.1205202, 9.5263962 47.1203624, 9.5262514 47.1203332, 9.5262675 47.120147, 9.5263478 47.1196992)) │ │ way/346498887 │ {layer=-1, tunnel=yes, waterway=stream} │ LINESTRING (9.5268863 47.1207926, 9.5268873 47.1208993) │ │ way/346498904 │ {waterway=stream} │ LINESTRING (9.5268834 47.1204249, 9.5268863 47.1207926) │ │ way/1408860175 │ {layer=-1, tunnel=culvert, waterway=stream} │ LINESTRING (9.5268852 47.1203714, 9.5268834 47.1204249) │ │ way/1408860174 │ {waterway=stream} │ LINESTRING (9.5268857 47.120271, 9.5268852 47.1203714) │ │ way/346498886 │ {layer=-1, tunnel=yes, waterway=stream} │ LINESTRING (9.5268932 47.1201946, 9.5268857 47.120271) │ │ way/346498970 │ {highway=service} │ LINESTRING (9.5270327 47.1196667, 9.5269768 47.1196621, 9.5269452 47.1197071, 9.5269138 47.1197529, 9.5268823 47.1197722, 9.5268423 47.1197688, 9.5267934 47.1197615, 9.5267022 47.1197408, 9.5267053 47.1197143) │ │ way/346498958 │ {highway=service} │ LINESTRING (9.5268696 47.1202405, 9.5269007 47.1202423, 9.5271015 47.1202335, 9.5271411 47.1202322, 9.527142 47.1201649) │ │ node/3530177044 │ {natural=tree} │ POINT (9.5270148 47.12015) │ │ way/284115535 │ {'addr:city'=Triesen, 'addr:country'=LI, 'addr:housenumber'=14, 'addr:postcode'=9495, 'addr:street'=Fürst-Johann-Strasse, building=yes} │ POLYGON ((9.5271205 47.1201349, 9.5272461 47.1201365, 9.5272489 47.1200365, 9.5271233 47.1200348, 9.5271205 47.1201349)) │ ├─────────────────┴─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┴───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤ │ ? rows (>9999 rows, 20 shown) 3 columns │ └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
Return data as GeoDataFrame¶
PbfFileReader
can also return the data in the GeoDataFrame form.
Here the caching strategy will be utilized - file won't be transformed again.
features_gdf = reader.convert_pbf_to_geodataframe(liechtenstein_pbf_file)
features_gdf
tags | geometry | |
---|---|---|
feature_id | ||
node/540308211 | {'power': 'tower'} | POINT (9.53724 46.98628) |
node/1338490716 | {'power': 'tower'} | POINT (9.53428 46.98876) |
node/540308206 | {'power': 'tower'} | POINT (9.53134 46.99121) |
node/540308180 | {'power': 'tower'} | POINT (9.52855 46.99365) |
node/540308170 | {'power': 'tower'} | POINT (9.52576 46.99609) |
... | ... | ... |
way/439890023 | {'natural': 'cliff'} | LINESTRING (9.60433 47.06468, 9.60382 47.06464... |
way/1195535494 | {'natural': 'grassland'} | POLYGON ((9.60181 47.06237, 9.60136 47.06238, ... |
node/540308216 | {'line_attachment': 'suspension', 'power': 'to... | POINT (9.54003 46.98396) |
node/1110282277 | {'power': 'tower'} | POINT (9.5405 46.98211) |
node/2186283697 | {'power': 'tower'} | POINT (9.54143 46.97844) |
58997 rows × 2 columns
Plot the forests using GeoPandas¶
Filter all polygons and features with landuse
=forest
.
features_gdf[
features_gdf.geom_type.isin(("Polygon", "MultiPolygon"))
& features_gdf.tags.apply(lambda x: "landuse" in x and x["landuse"] == "forest")
].plot(color="green")
<Axes: >