geopandas.GeoDataFrame.from_features#

classmethod GeoDataFrame.from_features(features, crs=None, columns=None)#

从可迭代的要素或要素集合创建GeoDataFrame的备用构造函数。

参数
features
  • 可迭代的功能,其中每个元素必须是功能词典或实现 __geo_interface__.

  • Feature集合,其中‘Feature’键包含可迭代的功能。

  • 对象,该对象包含实现 __geo_interface__

crs字符串或词典(可选)

要在结果框架上设置的坐标系。

columns列名列表,可选

或者,指定要包括在输出框架中的列名。这不会覆盖输入的属性名称,但可以确保输出格式一致。

退货
GeoDataFrame

注意事项

有关 __geo_interface__ ,请参阅https://gist.github.com/sgillies/2217756

示例

>>> feature_coll = {
...     "type": "FeatureCollection",
...     "features": [
...         {
...             "id": "0",
...             "type": "Feature",
...             "properties": {"col1": "name1"},
...             "geometry": {"type": "Point", "coordinates": (1.0, 2.0)},
...             "bbox": (1.0, 2.0, 1.0, 2.0),
...         },
...         {
...             "id": "1",
...             "type": "Feature",
...             "properties": {"col1": "name2"},
...             "geometry": {"type": "Point", "coordinates": (2.0, 1.0)},
...             "bbox": (2.0, 1.0, 2.0, 1.0),
...         },
...     ],
...     "bbox": (1.0, 1.0, 2.0, 2.0),
... }
>>> df = geopandas.GeoDataFrame.from_features(feature_coll)
>>> df
                  geometry   col1
0  POINT (1.00000 2.00000)  name1
1  POINT (2.00000 1.00000)  name2