从内存/ zip文件读取gpkg文件

问题描述

我知道可以通过以下方式从zip文件中读取shapefile:将其提取到内存中,然后再读取它: https://gis.stackexchange.com/questions/250092/using-pyshp-to-read-a-file-like-object-from-a-zipped-archive

Fiona还可以从内存中读取shapefile: https://pypi.org/project/Fiona/1.5.0/

但是,我一直无法找到以相同方式读取.gpkg(geopackage)的方法。

如何从zip文件中提取地理包,然后将其打包到geopandas地理数据框中?

解决方法

您可以通过在zip中指定gpkg的路径直接读取它。

    df = gpd.read_file('zip:///path/to/file.zip!data.gpkg')

相对路径:

    df = gpd.read_file('zip://../path/to/file.zip!data.gpkg')

(在需要返回目录然后进入“ path / to /”等的情况下

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...