我想使用geopandas读取geopackage文件,它可以使用layer =“''参数读取第一层或特定层。但是如何读取所有层?可能像:
all_layers = gp.read_xxxx('xxx.gpkg')
for layer in layers:
# fetch this layer
答案 0 :(得分:1)
您可以通过fiona和通过图层名进行操作 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))
如果您将其传递给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