10

I have a GeoPackage with multiple tables, and I am trying to load it with GeoPandas:

import geopandas as gpd

filename = '~/example.gpkg'
gdf = gpd.read_file(filename)'

This returns the first table/layer in the gpkg. Is there any way to access the other layer, i.e. something like:

filename = '~/example.gpkg|second_table'

I'm guessing I might need to use fiona directly, but couldn't figure it out from the docs.

1 Answer 1

14

Use the layer='...' parameter:

gdf = gpd.read_file(r'C:\folder\geopackage.gpkg', layer='somelayername')

See gpd.read_file's **kwargs parameter:

Keyword args to be passed to the engine, and can be used to write to multi-layer data, store data within archives (zip files), etc. In case of the “pyogrio” engine, the keyword arguments are passed to pyogrio.read_dataframe:

pyogrio.read_dataframe:

layer int or str, optional (default: first layer)

...If a string is provided, it must match the name of the layer in the data source. Defaults to first layer in data source...

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.