当有 .dbf、.prj、.shp 和 .shx 文件时,如何读取 geopandas 中的 shapefile?

I. *_*. A 1 shapefile python-3.x geopandas

我有一个包含形状文件的文件夹;更正式地说,我拥有的文件是:“.dbf”、“.prj”、“.shp”和“.shx”。现在,我通过以下方式读取形状文件:

shapefile_path = r".\canada.shp"
canada = geopandas.read_file(shapefile_path)
Run Code Online (Sandbox Code Playgroud)

但是其他文件呢?

任何帮助深表感谢!!

mar*_*eis 11

“.dbf”、“.prj”、“.shp”和“.shx”都是同一 ShapeFile 的部分。由于某种原因,SHP 的结构被分割成多个文件。如果您像上面那样将 .shp 读入 geopandas,它也会自动读取其余部分,为您提供由几何、属性和投影组成的正确 GeoDataFrame。您可以在Wiki上查看有关哪种文件类型的用途的详细信息。