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 0x7fba4bfcc710>)
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:19
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/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 │ │ way/107499300 │ POLYGON ((-21.7757411 64.1455954, -21.7756335 64.14558, -21.7755599 64.1456775, -21.7755993 64.1456831, -21.7755893 64.1456964, -21.7756575 64.1457061, -21.7757411 64.1455954)) │ residential │ │ way/107499268 │ POLYGON ((-21.7756335 64.14558, -21.775525 64.1455644, -21.7754422 64.1456742, -21.7755097 64.1456838, -21.7755189 64.1456716, -21.7755599 64.1456775, -21.7756335 64.14558)) │ residential │ ├────────────────┴────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┴──────────────┤ │ ? rows (>9999 rows, 20 shown) 3 columns │ └────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
Count all buildings¶
features_relation.count("feature_id")
┌───────────────────┐ │ count(feature_id) │ │ int64 │ ├───────────────────┤ │ 25390 │ └───────────────────┘
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:19
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... |
25390 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.019945 57.9941124, 22.0189449 57.993394, 22.0185402 57.9927809, 22.0183619 57.9919954, 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/195546717 │ LINESTRING (25.0451495 59.1910586, 25.0450268 59.1910643, 25.044908 59.1910475, 25.0448085 59.1910103, 25.0447409 59.1909574) │ tertiary │ │ way/422420997 │ LINESTRING (25.0447409 59.1909574, 25.0447141 59.1908814) │ tertiary │ │ way/422420999 │ LINESTRING (25.0447141 59.1908814, 25.0447519 59.1908081, 25.0448463 59.1907497, 25.0449798 59.1907171) │ tertiary │ │ way/320515550 │ LINESTRING (25.0447141 59.1908814, 25.04458 59.1907476, 25.0444226 59.1906162, 25.0441778 59.1904504, 25.0439104 59.1902824, 25.0434693 59.1900129) │ tertiary │ │ way/1078507717 │ LINESTRING (25.0458211 59.1899918, 25.0458076 59.1897874, 25.0458138 59.1895714, 25.0458819 59.1892617, 25.0460488 59.1888211) │ tertiary │ │ way/240544500 │ LINESTRING (25.057035 59.1885853, 25.056635 59.1886564, 25.0562347 59.1887223, 25.0559466 59.1887408, 25.0554716 59.1887585, 25.053962 59.1887548, 25.0535107 59.1887315, 25.0531502 59.1886987, 25.0528315 59.1886633, 25.052574 59.1886334, 25.0523151 59.1886237, 25.0520119 59.1886189, 25.0516152 59.1886326, 25.0511403 59.1886702, 25.050088 59.1886804, 25.0500031 59.1886812, 25.0486942 59.1886592, 25.0480065 59.1887007, 25.0470873 59.188791, 25.0466533 59.1888367, 25.0463221 59.1888503, 25.0461412 59.188831, 25.0460488 59.1888211) │ tertiary │ │ way/168043248 │ LINESTRING (25.0478109 59.1919858, 25.0473929 59.1918122) │ tertiary │ │ way/240544535 │ LINESTRING (25.0505407 59.1913464, 25.0502426 59.1914323, 25.0500822 59.1915124, 25.0499261 59.191631, 25.049687 59.1918016, 25.0495061 59.1919316) │ tertiary │ │ way/240544533 │ LINESTRING (25.0505407 59.1913464, 25.0507865 59.1912914, 25.0510235 59.1912589, 25.0511606 59.1912353, 25.0512476 59.1912047) │ tertiary │ │ way/205797907 │ POLYGON ((25.051522 59.1914037, 25.0514437 59.1914065, 25.0513673 59.191397, 25.0513001 59.1913762, 25.0512509 59.1913481, 25.0512192 59.191314, 25.0512078 59.1912766, 25.0512175 59.1912392, 25.0512476 59.1912047, 25.0513017 59.1911732, 25.0513725 59.191152, 25.0514526 59.1911433, 25.051534 59.1911479, 25.0515841 59.191158, 25.0516291 59.1911733, 25.0516844 59.1912057, 25.0517163 59.1912455, 25.0517215 59.1912885, 25.0516994 59.1913301, 25.0516561 59.1913636, 25.0515951 59.191389, 25.051522 59.1914037)) │ tertiary │ ├────────────────┴──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┴──────────┤ │ ? rows (>9999 rows, 20 shown) 3 columns │ └──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
Count loaded roads¶
features_relation.count("feature_id")
┌───────────────────┐ │ count(feature_id) │ │ int64 │ ├───────────────────┤ │ 26728 │ └───────────────────┘
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
29523.317850726122
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:07
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/284115543 │ {building=garage} │ POLYGON ((9.5271892 47.1202106, 9.5272628 47.1202068, 9.5272576 47.1201613, 9.5271841 47.1201652, 9.5271892 47.1202106)) │ │ way/346498820 │ {'addr:city'=Triesen, 'addr:country'=LI, 'addr:housenumber'=26, 'addr:postcode'=9495, 'addr:street'=Fürst-Johann-Strasse, building=yes} │ POLYGON ((9.5271199 47.120985, 9.5272657 47.1209773, 9.5272574 47.1209041, 9.5271116 47.1209117, 9.5271199 47.120985)) │ │ way/998707606 │ {'addr:city'=Triesen, 'addr:country'=LI, 'addr:housenumber'=20, 'addr:postcode'=9495, 'addr:street'=Fürst-Johann-Strasse, building=yes} │ POLYGON ((9.52725 47.120815, 9.52725 47.120622, 9.5271032 47.120622, 9.5271032 47.120815, 9.52725 47.120815)) │ │ way/998707605 │ {building=yes} │ POLYGON ((9.5272654 47.1204965, 9.5272641 47.1203213, 9.5270374 47.1203221, 9.5270387 47.1204973, 9.5272654 47.1204965)) │ │ way/346498822 │ {building=yes} │ POLYGON ((9.5269357 47.1207866, 9.5269694 47.1207866, 9.5269694 47.120731, 9.5269357 47.120731, 9.5269357 47.1207866)) │ │ way/38820004 │ {'cycleway:both'=no, highway=residential, lit=yes, maxspeed=50, name=Fürst-Johann-Strasse, 'source:maxspeed'=sign, surface=asphalt} │ LINESTRING (9.5264438 47.1223908, 9.5265493 47.1223074, 9.526655 47.1221891, 9.5267245 47.1220851, 9.5267669 47.1220107, 9.5267855 47.1219798, 9.5268282 47.1218756, 9.5268549 47.1217815, 9.5268656 47.1215636, 9.5268636 47.1214433, 9.5268596 47.1212091, 9.5268591 47.1211812, 9.5268624 47.120913, 9.5268616 47.1208588, 9.5268592 47.1207013, 9.5268626 47.1203445, 9.5268696 47.1202405, 9.5268703 47.1202308, 9.526871 47.1202197, 9.5268733 47.1201279, 9.5268879 47.1200445, 9.5269135 47.1199321, 9.5269905 47.1197434, 9.5270327 47.1196667, 9.5271829 47.1194624, 9.5272587 47.1193695, 9.5273984 47.1192452, 9.5274705 47.1191867, 9.5275315 47.1191553, 9.5276194 47.1191314, 9.5276585 47.1191224) │ │ way/485364899 │ {landuse=residential} │ POLYGON ((9.5273189 47.1198951, 9.5270461 47.119874, 9.5268994 47.1198626, 9.5268415 47.1200192, 9.5267985 47.1203843, 9.5268015 47.1209059, 9.5268093 47.1217568, 9.5267868 47.1218416, 9.5269517 47.1218345, 9.5269475 47.1215453, 9.5269595 47.1208302, 9.5269487 47.1202748, 9.5272921 47.1202675, 9.5273189 47.1198951)) │ │ way/346498935 │ {highway=service} │ LINESTRING (9.5268616 47.1208588, 9.526906 47.1208571, 9.5270452 47.1208553) │ │ way/284115742 │ {footway=sidewalk, highway=footway, lit=yes, surface=paving_stones} │ LINESTRING (9.5265758 47.1224124, 9.5266578 47.1223171, 9.5266649 47.1222822, 9.5266679 47.1222577, 9.5267146 47.1221943, 9.5267989 47.1220631, 9.5268283 47.1220222, 9.526874 47.121873, 9.5268929 47.1218137, 9.5269068 47.1217255, 9.5269032 47.1214418, 9.5269047 47.12121, 9.526906 47.1208571, 9.5269001 47.1204299, 9.5269007 47.1202423, 9.5269137 47.1201356, 9.5269381 47.1200409, 9.5269665 47.1199431, 9.5269992 47.1198527, 9.5270433 47.1197661, 9.5270962 47.1196684, 9.5271391 47.1195985, 9.5271928 47.1195218, 9.5272545 47.119454, 9.5272988 47.1193847) │ │ way/1408860176 │ {access=private, leisure=swimming_pool, location=outdoor, swimming_pool=personal} │ POLYGON ((9.5269752 47.1213156, 9.5269722 47.121278, 9.5270969 47.1212734, 9.5270999 47.1213111, 9.5269752 47.1213156)) │ ├─────────────────┴─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┴────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤ │ ? 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) |
58788 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: >