OSM PBF Loader¶
OSMPbfLoader
can really quickly parse full OSM extract in the form of *.osm.pbf
file.
It can download and parse a lot of features much faster than the OSMOnlineLoader
, but it's much more useful when a lot of different features are required at once (like when using predefined filters).
When only a single or few features are needed, OSMOnlineLoader
might be a better choice, since OSMPbfLoader
will use a full extract of all features in a given region and will have to iterate over all of them.
In [1]:
Copied!
import geopandas as gpd
from shapely.geometry import Point, box
from srai.constants import REGIONS_INDEX, WGS84_CRS
from srai.geometry import buffer_geometry
from srai.loaders.osm_loaders import OSMPbfLoader
from srai.loaders.osm_loaders.filters import GEOFABRIK_LAYERS, HEX2VEC_FILTER
from srai.loaders.osm_loaders.filters.popular import get_popular_tags
from srai.regionalizers import geocode_to_region_gdf
import geopandas as gpd
from shapely.geometry import Point, box
from srai.constants import REGIONS_INDEX, WGS84_CRS
from srai.geometry import buffer_geometry
from srai.loaders.osm_loaders import OSMPbfLoader
from srai.loaders.osm_loaders.filters import GEOFABRIK_LAYERS, HEX2VEC_FILTER
from srai.loaders.osm_loaders.filters.popular import get_popular_tags
from srai.regionalizers import geocode_to_region_gdf
Using OSMPbfLoader to download data for a specific area¶
Download all features from HEX2VEC_FILTER
in Warsaw, Poland¶
In [2]:
Copied!
loader = OSMPbfLoader()
warsaw_gdf = geocode_to_region_gdf("Warsaw, Poland")
warsaw_features_gdf = loader.load(warsaw_gdf, HEX2VEC_FILTER)
warsaw_features_gdf
loader = OSMPbfLoader()
warsaw_gdf = geocode_to_region_gdf("Warsaw, Poland")
warsaw_features_gdf = loader.load(warsaw_gdf, HEX2VEC_FILTER)
warsaw_features_gdf
/opt/hostedtoolcache/Python/3.10.16/x64/lib/python3.10/site-packages/pyogrio/geopandas.py:662: UserWarning: 'crs' was not provided. The output dataset will not have projection information defined and may not be usable in other systems. write(
/opt/hostedtoolcache/Python/3.10.16/x64/lib/python3.10/site-packages/geopandas/array.py:1638: UserWarning: CRS not set for some of the concatenation inputs. Setting output's CRS as WGS 84 (the single non-null crs provided). return GeometryArray(data, crs=_get_common_crs(to_concat))
Finished operation in 0:00:54
Out[2]:
geometry | aeroway | amenity | building | healthcare | historic | landuse | leisure | military | natural | office | shop | sport | tourism | water | waterway | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
feature_id | ||||||||||||||||
node/1256077910 | POINT (21.06084 52.14127) | None | None | None | None | None | None | None | None | None | None | bicycle | None | None | None | None |
node/1256078032 | POINT (21.05859 52.13092) | None | None | None | None | None | None | None | None | None | None | bicycle | None | None | None | None |
node/1257158928 | POINT (21.03517 52.14134) | None | None | None | None | None | None | None | None | None | None | convenience | None | None | None | None |
node/1257158933 | POINT (21.03589 52.14303) | None | None | None | None | None | None | None | None | None | None | convenience | None | None | None | None |
node/1257158946 | POINT (21.02488 52.14098) | None | None | None | None | None | None | None | None | None | None | doityourself | None | None | None | None |
... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
relation/13473201 | POLYGON ((20.968 52.26484, 20.96809 52.26496, ... | None | None | apartments | None | None | None | None | None | None | None | None | None | None | None | None |
relation/12274648 | MULTIPOLYGON (((21.13682 52.24065, 21.13683 52... | None | None | apartments | None | None | None | None | None | None | None | None | None | None | None | None |
relation/13155345 | POLYGON ((21.01428 52.21057, 21.01427 52.2106,... | None | None | None | None | None | None | track | None | None | None | None | running | None | None | None |
relation/14028630 | MULTIPOLYGON (((21.10168 52.20114, 21.10167 52... | None | None | None | None | None | None | None | None | scrub | None | None | None | None | None | None |
relation/11876626 | POLYGON ((20.99684 52.12547, 20.99676 52.12551... | None | None | None | None | None | None | None | None | scrub | None | None | None | None | None | None |
334049 rows × 16 columns
Plot features¶
Inspired by prettymaps
In [3]:
Copied!
clipped_features_gdf = warsaw_features_gdf.clip(warsaw_gdf.geometry.union_all())
clipped_features_gdf = warsaw_features_gdf.clip(warsaw_gdf.geometry.union_all())
In [4]:
Copied!
ax = warsaw_gdf.plot(color="lavender", figsize=(16, 16))
# plot water
clipped_features_gdf.dropna(subset=["water", "waterway"], how="all").plot(
ax=ax, color="deepskyblue"
)
# plot greenery
clipped_features_gdf[
clipped_features_gdf["landuse"].isin(
["grass", "orchard", "flowerbed", "forest", "greenfield", "meadow"]
)
].plot(ax=ax, color="mediumseagreen")
# plot buildings
clipped_features_gdf.dropna(subset=["building"], how="all").plot(
ax=ax, color="dimgray", markersize=0.1
)
xmin, ymin, xmax, ymax = warsaw_gdf.total_bounds
ax.set_xlim(xmin, xmax)
ax.set_ylim(ymin, ymax)
ax.set_axis_off()
ax = warsaw_gdf.plot(color="lavender", figsize=(16, 16))
# plot water
clipped_features_gdf.dropna(subset=["water", "waterway"], how="all").plot(
ax=ax, color="deepskyblue"
)
# plot greenery
clipped_features_gdf[
clipped_features_gdf["landuse"].isin(
["grass", "orchard", "flowerbed", "forest", "greenfield", "meadow"]
)
].plot(ax=ax, color="mediumseagreen")
# plot buildings
clipped_features_gdf.dropna(subset=["building"], how="all").plot(
ax=ax, color="dimgray", markersize=0.1
)
xmin, ymin, xmax, ymax = warsaw_gdf.total_bounds
ax.set_xlim(xmin, xmax)
ax.set_ylim(ymin, ymax)
ax.set_axis_off()
Download all features from popular tags based on OSMTagInfo in Vienna, Austria¶
In [5]:
Copied!
popular_tags = get_popular_tags(in_wiki_only=True)
num_keys = len(popular_tags)
f"Unique keys: {num_keys}."
popular_tags = get_popular_tags(in_wiki_only=True)
num_keys = len(popular_tags)
f"Unique keys: {num_keys}."
Out[5]:
'Unique keys: 363.'
In [6]:
Copied!
{k: popular_tags[k] for k in list(popular_tags)[:10]}
{k: popular_tags[k] for k in list(popular_tags)[:10]}
Out[6]:
{'4wd_only': ['yes'], 'LandPro08:reviewed': ['no'], 'abandoned': ['yes'], 'abandoned:railway': ['rail'], 'abutters': ['residential'], 'access': ['agricultural', 'customers', 'delivery', 'designated', 'destination', 'forestry', 'no', 'permissive', 'permit', 'private', 'unknown', 'yes'], 'addr:TW:dataset': ['137998'], 'addr:country': ['CZ', 'DE', 'RU', 'US'], 'addr:state': ['AZ', 'CA', 'CO', 'CT', 'FL', 'IN', 'KY', 'MD', 'ME', 'NC', 'NJ', 'NY', 'PA', 'TX'], 'admin_level': ['10', '11', '2', '4', '5', '6', '7', '8', '9']}
In [7]:
Copied!
vienna_center_circle = buffer_geometry(Point(16.37009, 48.20931), meters=1000)
vienna_center_circle_gdf = gpd.GeoDataFrame(
geometry=[vienna_center_circle],
crs=WGS84_CRS,
index=gpd.pd.Index(data=["Vienna"], name=REGIONS_INDEX),
)
vienna_center_circle = buffer_geometry(Point(16.37009, 48.20931), meters=1000)
vienna_center_circle_gdf = gpd.GeoDataFrame(
geometry=[vienna_center_circle],
crs=WGS84_CRS,
index=gpd.pd.Index(data=["Vienna"], name=REGIONS_INDEX),
)
In [8]:
Copied!
loader = OSMPbfLoader()
vienna_features_gdf = loader.load(vienna_center_circle_gdf, popular_tags)
vienna_features_gdf
loader = OSMPbfLoader()
vienna_features_gdf = loader.load(vienna_center_circle_gdf, popular_tags)
vienna_features_gdf
/opt/hostedtoolcache/Python/3.10.16/x64/lib/python3.10/site-packages/geopandas/array.py:1638: UserWarning: CRS not set for some of the concatenation inputs. Setting output's CRS as WGS 84 (the single non-null crs provided). return GeometryArray(data, crs=_get_common_crs(to_concat))
/opt/hostedtoolcache/Python/3.10.16/x64/lib/python3.10/site-packages/quackosm/pb f_file_reader.py:2614: UserWarning: Select clause contains more than 100 columns (found 363 columns). Query might fail with insufficient memory resources. Consider applying more restrictive OsmTagsFilter for parsing. warnings.warn(
Finished operation in 0:00:29
Out[8]:
geometry | abandoned | access | admin_level | advertising | amenity | area:highway | artwork_type | atm | barrier | ... | tunnel | type | usage | vehicle | vending | waste | water | water_source | waterway | wheelchair | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
feature_id | |||||||||||||||||||||
node/33182886 | POINT (16.36631 48.20782) | None | None | None | None | None | None | None | None | None | ... | None | None | None | None | None | None | None | None | None | None |
node/33182965 | POINT (16.37033 48.20359) | None | None | None | None | None | None | None | None | None | ... | None | None | None | None | None | None | None | None | None | None |
node/33344361 | POINT (16.36484 48.2159) | None | None | None | None | None | None | None | None | None | ... | None | None | None | None | None | None | None | None | None | None |
node/33344362 | POINT (16.36413 48.21558) | None | None | None | None | None | None | None | None | None | ... | None | None | None | None | None | None | None | None | None | None |
node/34591548 | POINT (16.36967 48.20235) | None | None | None | None | None | None | None | None | None | ... | None | None | None | None | None | None | None | None | None | None |
... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
way/1307912491 | LINESTRING (16.36757 48.21027, 16.36758 48.210... | None | None | None | None | None | None | None | None | retaining_wall | ... | None | None | None | None | None | None | None | None | None | None |
way/1307912492 | LINESTRING (16.36772 48.21017, 16.36773 48.210... | None | None | None | None | None | None | None | None | retaining_wall | ... | None | None | None | None | None | None | None | None | None | None |
way/1307912493 | LINESTRING (16.36801 48.21, 16.36813 48.20992,... | None | None | None | None | None | None | None | None | retaining_wall | ... | None | None | None | None | None | None | None | None | None | None |
way/1307912494 | LINESTRING (16.36814 48.20991, 16.36814 48.209... | None | None | None | None | None | None | None | None | retaining_wall | ... | None | None | None | None | None | None | None | None | None | None |
way/1307913342 | POLYGON ((16.36802 48.21466, 16.36806 48.21462... | None | None | None | None | None | None | None | None | fence | ... | None | None | None | None | None | None | None | None | None | None |
22746 rows × 191 columns
Plot features¶
Uses default
preset colours from prettymaps
In [9]:
Copied!
clipped_vienna_features_gdf = vienna_features_gdf.clip(vienna_center_circle)
clipped_vienna_features_gdf = vienna_features_gdf.clip(vienna_center_circle)
In [10]:
Copied!
ax = vienna_center_circle_gdf.plot(color="#F2F4CB", figsize=(16, 16))
# plot water
clipped_vienna_features_gdf.dropna(subset=["water", "waterway"], how="all").plot(
ax=ax, color="#a8e1e6"
)
# plot streets
clipped_vienna_features_gdf.dropna(subset=["highway"], how="all").plot(
ax=ax, color="#475657", markersize=0.1
)
# plot buildings
clipped_vienna_features_gdf.dropna(subset=["building"], how="all").plot(ax=ax, color="#FF5E5B")
# plot parkings
clipped_vienna_features_gdf[
(clipped_vienna_features_gdf["amenity"] == "parking")
| (clipped_vienna_features_gdf["highway"] == "pedestrian")
].plot(ax=ax, color="#2F3737", markersize=0.1)
# plot greenery
clipped_vienna_features_gdf[
clipped_vienna_features_gdf["landuse"].isin(
["grass", "orchard", "flowerbed", "forest", "greenfield", "meadow"]
)
].plot(ax=ax, color="#8BB174")
xmin, ymin, xmax, ymax = vienna_center_circle_gdf.total_bounds
ax.set_xlim(xmin, xmax)
ax.set_ylim(ymin, ymax)
ax.set_axis_off()
ax = vienna_center_circle_gdf.plot(color="#F2F4CB", figsize=(16, 16))
# plot water
clipped_vienna_features_gdf.dropna(subset=["water", "waterway"], how="all").plot(
ax=ax, color="#a8e1e6"
)
# plot streets
clipped_vienna_features_gdf.dropna(subset=["highway"], how="all").plot(
ax=ax, color="#475657", markersize=0.1
)
# plot buildings
clipped_vienna_features_gdf.dropna(subset=["building"], how="all").plot(ax=ax, color="#FF5E5B")
# plot parkings
clipped_vienna_features_gdf[
(clipped_vienna_features_gdf["amenity"] == "parking")
| (clipped_vienna_features_gdf["highway"] == "pedestrian")
].plot(ax=ax, color="#2F3737", markersize=0.1)
# plot greenery
clipped_vienna_features_gdf[
clipped_vienna_features_gdf["landuse"].isin(
["grass", "orchard", "flowerbed", "forest", "greenfield", "meadow"]
)
].plot(ax=ax, color="#8BB174")
xmin, ymin, xmax, ymax = vienna_center_circle_gdf.total_bounds
ax.set_xlim(xmin, xmax)
ax.set_ylim(ymin, ymax)
ax.set_axis_off()
Download all grouped features based on Geofabrik layers in New York, USA¶
In [11]:
Copied!
manhattan_bbox = box(-73.994551, 40.762396, -73.936872, 40.804239)
manhattan_bbox_gdf = gpd.GeoDataFrame(
geometry=[manhattan_bbox],
crs=WGS84_CRS,
index=gpd.pd.Index(data=["New York"], name=REGIONS_INDEX),
)
manhattan_bbox = box(-73.994551, 40.762396, -73.936872, 40.804239)
manhattan_bbox_gdf = gpd.GeoDataFrame(
geometry=[manhattan_bbox],
crs=WGS84_CRS,
index=gpd.pd.Index(data=["New York"], name=REGIONS_INDEX),
)
In [12]:
Copied!
loader = OSMPbfLoader()
new_york_features_gdf = loader.load(manhattan_bbox_gdf, GEOFABRIK_LAYERS)
new_york_features_gdf
loader = OSMPbfLoader()
new_york_features_gdf = loader.load(manhattan_bbox_gdf, GEOFABRIK_LAYERS)
new_york_features_gdf
/opt/hostedtoolcache/Python/3.10.16/x64/lib/python3.10/site-packages/geopandas/array.py:1638: UserWarning: CRS not set for some of the concatenation inputs. Setting output's CRS as WGS 84 (the single non-null crs provided). return GeometryArray(data, crs=_get_common_crs(to_concat)) /opt/hostedtoolcache/Python/3.10.16/x64/lib/python3.10/site-packages/quackosm/osm_extracts/__init__.py:602: GeometryNotCoveredWarning: Skipping extract because of low IoU value (bbbike_newyork, 0.000187). warnings.warn(
Finished operation in 0:00:34
Out[12]:
geometry | accommodation | buildings | catering | education | fuel_parking | health | highway_links | landuse | leisure | ... | public | railways | shopping | tourism | traffic | transport | very_small_roads | water | water_traffic | waterways | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
feature_id | |||||||||||||||||||||
node/462004948 | POINT (-73.95553 40.77949) | None | None | None | None | None | None | None | None | None | ... | None | None | None | None | None | railway=station | None | None | None | None |
node/480491548 | POINT (-73.96358 40.78135) | None | None | None | None | None | None | None | None | None | ... | None | None | None | None | highway=crossing | None | None | None | None | None |
node/480492539 | POINT (-73.96863 40.77474) | None | None | None | None | None | None | None | None | None | ... | None | None | None | None | highway=crossing | None | None | None | None | None |
node/480492646 | POINT (-73.96828 40.77501) | None | None | None | None | None | None | None | None | None | ... | None | None | None | None | highway=crossing | None | None | None | None | None |
node/480492947 | POINT (-73.9665 40.7781) | None | None | None | None | None | None | None | None | None | ... | None | None | None | None | highway=crossing | None | None | None | None | None |
... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
way/1268043418 | POLYGON ((-73.96235 40.80165, -73.96205 40.802... | None | None | None | None | None | None | None | landuse=residential | None | ... | None | None | None | None | None | None | None | None | None | None |
way/1268046833 | POLYGON ((-73.96263 40.80375, -73.96255 40.803... | None | None | None | None | None | None | None | None | leisure=playground | ... | None | None | None | None | None | None | None | None | None | None |
way/1268093037 | LINESTRING (-73.9431 40.79926, -73.94337 40.79... | None | None | None | None | None | None | None | None | None | ... | None | None | None | None | None | None | None | None | None | None |
way/1268093038 | LINESTRING (-73.9431 40.79926, -73.94303 40.79... | None | None | None | None | None | None | None | None | None | ... | None | None | None | None | None | None | None | None | None | None |
way/1270720402 | LINESTRING (-73.96216 40.80333, -73.96188 40.8... | None | None | None | None | None | None | None | None | None | ... | None | None | None | None | None | None | None | None | None | None |
49467 rows × 27 columns
Plot features¶
Inspired by https://snazzymaps.com/style/14889/flat-pale
In [13]:
Copied!
ax = manhattan_bbox_gdf.plot(color="#e7e7df", figsize=(16, 16))
# plot greenery
new_york_features_gdf[new_york_features_gdf["leisure"] == "leisure=park"].plot(
ax=ax, color="#bae5ce"
)
# plot water
new_york_features_gdf.dropna(subset=["water", "waterways"], how="all").plot(ax=ax, color="#c7eced")
# plot streets
new_york_features_gdf.dropna(subset=["paths_unsuitable_for_cars"], how="all").plot(
ax=ax, color="#e7e7df", linewidth=1
)
new_york_features_gdf.dropna(
subset=["very_small_roads", "highway_links", "minor_roads"], how="all"
).plot(ax=ax, color="#fff", linewidth=2)
new_york_features_gdf.dropna(subset=["major_roads"], how="all").plot(
ax=ax, color="#fac9a9", linewidth=3
)
# plot buildings
new_york_features_gdf.dropna(subset=["buildings"], how="all").plot(ax=ax, color="#cecebd")
xmin, ymin, xmax, ymax = manhattan_bbox_gdf.total_bounds
ax.set_xlim(xmin, xmax)
ax.set_ylim(ymin, ymax)
ax.set_axis_off()
ax = manhattan_bbox_gdf.plot(color="#e7e7df", figsize=(16, 16))
# plot greenery
new_york_features_gdf[new_york_features_gdf["leisure"] == "leisure=park"].plot(
ax=ax, color="#bae5ce"
)
# plot water
new_york_features_gdf.dropna(subset=["water", "waterways"], how="all").plot(ax=ax, color="#c7eced")
# plot streets
new_york_features_gdf.dropna(subset=["paths_unsuitable_for_cars"], how="all").plot(
ax=ax, color="#e7e7df", linewidth=1
)
new_york_features_gdf.dropna(
subset=["very_small_roads", "highway_links", "minor_roads"], how="all"
).plot(ax=ax, color="#fff", linewidth=2)
new_york_features_gdf.dropna(subset=["major_roads"], how="all").plot(
ax=ax, color="#fac9a9", linewidth=3
)
# plot buildings
new_york_features_gdf.dropna(subset=["buildings"], how="all").plot(ax=ax, color="#cecebd")
xmin, ymin, xmax, ymax = manhattan_bbox_gdf.total_bounds
ax.set_xlim(xmin, xmax)
ax.set_ylim(ymin, ymax)
ax.set_axis_off()
Using OSMPbfLoader to download data for a specific area and transforming it to GeoParquet file¶
Download all grouped features based on Geofabrik layers in Reykjavík, Iceland¶
In [14]:
Copied!
loader = OSMPbfLoader()
reykjavik_gdf = geocode_to_region_gdf("Reykjavík, IS")
reykjavik_features_gpq = loader.load_to_geoparquet(reykjavik_gdf, GEOFABRIK_LAYERS)
reykjavik_features_gpq
loader = OSMPbfLoader()
reykjavik_gdf = geocode_to_region_gdf("Reykjavík, IS")
reykjavik_features_gpq = loader.load_to_geoparquet(reykjavik_gdf, GEOFABRIK_LAYERS)
reykjavik_features_gpq
/opt/hostedtoolcache/Python/3.10.16/x64/lib/python3.10/site-packages/geopandas/array.py:1638: UserWarning: CRS not set for some of the concatenation inputs. Setting output's CRS as WGS 84 (the single non-null crs provided). return GeometryArray(data, crs=_get_common_crs(to_concat))
Finished operation in 0:00:22
Out[14]:
PosixPath('files/4e8a6f659f407cf02e3da5661575f63ce8a59a7d27bbf3e8751b97e290553593_098931824b94bfe02e01bc4987422a39ec47bd3f6924e5325ddae0846badafba_exploded.parquet')
Read those features using DuckDB¶
In [15]:
Copied!
import duckdb
connection = duckdb.connect()
connection.load_extension("parquet")
connection.load_extension("spatial")
features_relation = connection.read_parquet(str(reykjavik_features_gpq))
features_relation
import duckdb
connection = duckdb.connect()
connection.load_extension("parquet")
connection.load_extension("spatial")
features_relation = connection.read_parquet(str(reykjavik_features_gpq))
features_relation
Out[15]:
┌────────────────┬───────────────┬─────────────┬───────────┬──────────┬───────────┬──────────────┬─────────┬───────────────┬─────────┬─────────┬─────────────┬─────────────┬─────────┬─────────┬─────────┬───────────────────────────┬─────────┬─────────┬──────────┬──────────┬─────────┬─────────────────────────┬───────────┬──────────────────┬─────────┬───────────────┬───────────┬──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ │ feature_id │ accommodation │ air_traffic │ buildings │ catering │ education │ fuel_parking │ health │ highway_links │ landuse │ leisure │ major_roads │ minor_roads │ miscpoi │ money │ natural │ paths_unsuitable_for_cars │ pofw │ public │ railways │ shopping │ tourism │ traffic │ transport │ very_small_roads │ water │ water_traffic │ waterways │ geometry │ │ varchar │ varchar │ varchar │ varchar │ varchar │ varchar │ varchar │ varchar │ varchar │ varchar │ varchar │ varchar │ varchar │ varchar │ varchar │ varchar │ varchar │ varchar │ varchar │ varchar │ varchar │ varchar │ varchar │ varchar │ varchar │ varchar │ varchar │ varchar │ geometry │ ├────────────────┼───────────────┼─────────────┼───────────┼──────────┼───────────┼──────────────┼─────────┼───────────────┼─────────┼─────────┼─────────────┼─────────────┼─────────┼─────────┼─────────┼───────────────────────────┼─────────┼─────────┼──────────┼──────────┼─────────┼─────────────────────────┼───────────┼──────────────────┼─────────┼───────────────┼───────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤ │ node/285118095 │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ highway=traffic_signals │ NULL │ NULL │ NULL │ NULL │ NULL │ POINT (-21.8832398 64.140129) │ │ node/285325367 │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ highway=crossing │ NULL │ NULL │ NULL │ NULL │ NULL │ POINT (-21.9145215 64.1434656) │ │ node/286073217 │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ highway=crossing │ NULL │ NULL │ NULL │ NULL │ NULL │ POINT (-21.9038514 64.1424288) │ │ node/286073228 │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ highway=crossing │ NULL │ NULL │ NULL │ NULL │ NULL │ POINT (-21.893188 64.1402736) │ │ node/286073230 │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ highway=crossing │ NULL │ NULL │ NULL │ NULL │ NULL │ POINT (-21.8929198 64.140261) │ │ node/286073238 │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ highway=crossing │ NULL │ NULL │ NULL │ NULL │ NULL │ POINT (-21.8875864 64.1404209) │ │ node/286073317 │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ highway=crossing │ NULL │ NULL │ NULL │ NULL │ NULL │ POINT (-21.8704922 64.1343781) │ │ node/286073340 │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ highway=crossing │ NULL │ NULL │ NULL │ NULL │ NULL │ POINT (-21.8681228 64.1329485) │ │ node/286073352 │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ highway=crossing │ NULL │ NULL │ NULL │ NULL │ NULL │ POINT (-21.8676131 64.1330594) │ │ node/286075056 │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ highway=crossing │ NULL │ NULL │ NULL │ NULL │ NULL │ POINT (-21.8551605 64.1284286) │ │ · │ · │ · │ · │ · │ · │ · │ · │ · │ · │ · │ · │ · │ · │ · │ · │ · │ · │ · │ · │ · │ · │ · │ · │ · │ · │ · │ · │ · │ │ · │ · │ · │ · │ · │ · │ · │ · │ · │ · │ · │ · │ · │ · │ · │ · │ · │ · │ · │ · │ · │ · │ · │ · │ · │ · │ · │ · │ · │ │ · │ · │ · │ · │ · │ · │ · │ · │ · │ · │ · │ · │ · │ · │ · │ · │ · │ · │ · │ · │ · │ · │ · │ · │ · │ · │ · │ · │ · │ │ way/92542359 │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ highway=footway │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ LINESTRING (-21.9334608 64.1486637, -21.9334542 64.1486607, -21.9334497 64.1486547, -21.933447 64.1486446, -21.9335005 64.1484741) │ │ way/92542361 │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ highway=path │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ LINESTRING (-21.7894267 64.1328444, -21.7893891 64.1328919, -21.7890464 64.1333447) │ │ way/92542364 │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ highway=footway │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ LINESTRING (-21.789387 64.1334488, -21.789283 64.1333645) │ │ way/92542368 │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ highway=footway │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ LINESTRING (-21.7747573 64.1530113, -21.7742187 64.1533179, -21.7742163 64.1533295) │ │ way/92542370 │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ highway=footway │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ LINESTRING (-21.7974488 64.1531215, -21.7972424 64.1531192) │ │ way/92542371 │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ highway=path │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ LINESTRING (-21.7666977 64.1254919, -21.7664941 64.125445, -21.7663998 64.1254601, -21.7662694 64.125526, -21.7662066 64.1255431, -21.7661036 64.1255609, -21.7644177 64.1255526, -21.7642442 64.1255507, -21.7641364 64.1255615, -21.7640614 64.1255771, -21.7639869 64.1255979, -21.7637668 64.1256861) │ │ way/92542372 │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ highway=path │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ LINESTRING (-21.8839423 64.1402961, -21.8839348 64.1403251, -21.8839962 64.1403686, -21.8842078 64.1405031, -21.8842321 64.140534, -21.8842362 64.1405799, -21.8842238 64.1407136, -21.8842348 64.140763, -21.8842815 64.1408086, -21.8846139 64.1409695, -21.8846583 64.1410109, -21.8852173 64.1411083, -21.8858988 64.1412374, -21.8861371 64.1413034, -21.8863133 64.1413547, -21.8864169 64.1413702, -21.8865156 64.1413726, -21.8866592 64.141372, -21.8882978 64.1413646, -21.8886062 64.1413632, -21.8890015 64.1414378, -21.8896611 64.1415627, -21.8906701 64.1417533, -21.8908687 64.1417909, -21.8913318 64.1418786, -21.8920984 64.1417461, -21.8922584 64.1417005) │ │ way/92542385 │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ highway=footway │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ LINESTRING (-21.9415543 64.142972, -21.9419359 64.1429957) │ │ way/92542388 │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ highway=path │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ LINESTRING (-21.8130548 64.1342656, -21.8132662 64.1343182) │ │ way/92542389 │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ highway=path │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ NULL │ LINESTRING (-21.7380212 64.108171, -21.7381771 64.1081746, -21.7383796 64.1081944, -21.7385458 64.108172, -21.7386667 64.1081772, -21.7388726 64.1082475, -21.7390724 64.108288, -21.7394436 64.1084158, -21.7397344 64.1085265, -21.7397959 64.108545, -21.7400505 64.1086783, -21.7401871 64.1088855, -21.7403349 64.1090119, -21.7405957 64.109137, -21.740976 64.1093023, -21.7412996 64.1093872, -21.7418552 64.1095057, -21.7420475 64.1095559, -21.7423119 64.1095838, -21.7426547 64.1095866, -21.7428875 64.1095499, -21.7433209 64.1094567, -21.7434568 64.10942, -21.7437155 64.1093946, -21.7441166 64.1093437, -21.744634 64.1093409, -21.7448611 64.109373, -21.7450673 64.1094639, -21.7455022 64.1095335, -21.7458789 64.1095912, -21.7463077 64.1096946, -21.7466648 64.1096716, -21.7470629 64.1097347, -21.7475894 64.109722, -21.7478537 64.1097464, -21.7482275 64.1097698, -21.7486047 64.1098621, -21.7489684 64.1100303, -21.7492501 64.1100999, -21.7494646 64.1101276, -21.7497196 64.1103197, -21.7498052 64.1104057) │ ├────────────────┴───────────────┴─────────────┴───────────┴──────────┴───────────┴──────────────┴─────────┴───────────────┴─────────┴─────────┴─────────────┴─────────────┴─────────┴─────────┴─────────┴───────────────────────────┴─────────┴─────────┴──────────┴──────────┴─────────┴─────────────────────────┴───────────┴──────────────────┴─────────┴───────────────┴───────────┴──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤ │ ? rows (>9999 rows, 20 shown) 29 columns │ └──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
Count all buildings¶
In [16]:
Copied!
features_relation.filter("buildings IS NOT NULL").count("feature_id")
features_relation.filter("buildings IS NOT NULL").count("feature_id")
Out[16]:
┌───────────────────┐ │ count(feature_id) │ │ int64 │ ├───────────────────┤ │ 25367 │ └───────────────────┘