首页 > 解决方案 > Geopandas 在读取 shp 文件时抛出驱动错误

问题描述

Geopandas 在读取 SHP 文件时引发驱动程序错误。

DriverError: '*PATH*/cb_2018_us_zcta510_500k.shp does not exist in the file system, and is not recognized as a supported dataset name.

我正在做的就是:

import geopandas
geopandas.read_file("*PATH*/cb_2018_us_zcta510_500k.shp")

从中提取的目录包括从此处下载的所有其他所需文件:

https://www.census.gov/geographies/mapping-files/time-series/geo/carto-boundary-file.html

实际文件在这里: https ://www2.census.gov/geo/tiger/GENZ2018/shp/cb_2018_us_zcta510_500k.zip

只是为了确认文件没有损坏或我在 QGis 中打开它并且它完美地拉起。

标签: pythondrivergisgeopandas

解决方案


如果其他人需要类似的信息:我也有一个合法的 shapefile URL,GeoPandas read_file 抛出了一个错误:DriverError not recognized as a supported file format.

对我有用的是以下内容:

import fiona

with fiona.open('/path/to/my_shapefile.shp') as shp:
   ax = geo.plot()
   #...rest of code

推荐阅读