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
GeoPandas supports writing and reading the Apache Parquet and Feather file formats.
Yes, GeoPandas support layers.
Use the geopackage driver gdal.org/drivers/vector/gpkg.html from OGR in python or shell the command (subprocess. Popen(['ogr2ogr', '-f', '"esri shapefile"', os. path. join(os.
GeoPandas is an open source project to make working with geospatial data in python easier. GeoPandas extends the datatypes used by pandas to allow spatial operations on geometric types. Geometric operations are performed by shapely. Geopandas further depends on fiona for file access and matplotlib for plotting.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With