I want to use geopandas read a geopackage file, It can read the first layer or specific layer with layer='' parameter. But how can it read all layers? May be like:
all_layers = gp.read_xxxx('xxx.gpkg')
for layer in layers:
# fetch this layer
I want to use geopandas read a geopackage file, It can read the first layer or specific layer with layer='' parameter. But how can it read all layers? May be like:
all_layers = gp.read_xxxx('xxx.gpkg')
for layer in layers:
# fetch this layer
You can do this by fiona and itter through the layernames https://fiona.readthedocs.io/en/latest/README.html#reading-multilayer-data
for layername in fiona.listlayers('tests/data.gpkg'):
with fiona.open('tests/data.gpkg', layer=layername) as src:
print(layername, len(src))
If you pass it to geopandas:
for layername in fiona.listlayers('test/data.gpkg'):
geopkg = gpd.read_file(r'test/data.gpkg', layer=layername)
i = 0
for name in geopkg.columns:
print(name)
i += 1
geopandas.read_file("package.gpkg", layer='layername')
. geopandas.org/en/stable/docs/user_guide/io.html –
Gorlicki © 2022 - 2024 — McMap. All rights reserved.
read_file
call results in a single GeoDataFrame). It would be nice to have some functionality for this, though. Feel free to open an issue on github: github.com/geopandas/geopandas. One option might also be to be able to list the layers, so you can loop through those and use read_file within the loop. – Consumable