geopandas.GeoDataFrame.from_file#

classmethod GeoDataFrame.from_file(filename, **kwargs)#

替代构造函数以创建 GeoDataFrame 从一个文件中。

建议使用 geopandas.read_file() 取而代之的是。

可以加载一个 GeoDataFrame 从可识别的任何格式的文件 fiona 。有关详细信息,请参阅http://fiona.readthedocs.io/en/latest/manual.html。

参数
filename应力

要从中读取的文件路径或文件句柄。根据包含的kwarg,文件名的内容可能会有所不同。有关使用详情,请参阅http://fiona.readthedocs.io/en/latest/README.html#usage。

kwargs关键字参数

这些参数被传递给fiona.open,并可用于访问多层数据、存储在存档(Zip文件)中的数据等。

参见

read_file

将文件读取到GeoDataFame

GeoDataFrame.to_file

将GeoDataFrame写入文件

示例

>>> path = geopandas.datasets.get_path('nybb')
>>> gdf = geopandas.GeoDataFrame.from_file(path)
>>> gdf  
   BoroCode       BoroName     Shape_Leng    Shape_Area                                           geometry
0         5  Staten Island  330470.010332  1.623820e+09  MULTIPOLYGON (((970217.022 145643.332, 970227....
1         4         Queens  896344.047763  3.045213e+09  MULTIPOLYGON (((1029606.077 156073.814, 102957...
2         3       Brooklyn  741080.523166  1.937479e+09  MULTIPOLYGON (((1021176.479 151374.797, 102100...
3         1      Manhattan  359299.096471  6.364715e+08  MULTIPOLYGON (((981219.056 188655.316, 980940....
4         2          Bronx  464392.991824  1.186925e+09  MULTIPOLYGON (((1012821.806 229228.265, 101278...

建议的读取文件的方法是 geopandas.read_file()

>>> gdf = geopandas.read_file(path)