geopandas.GeoDataFrame.__geo_interface__#
- property GeoDataFrame.__geo_interface__[来源]#
返回一个
GeoDataFrame作为一个 python 特征集合。实现了geo_interface。返回的python数据结构表示一个
GeoDataFrame,类似于GeoJSON的FeatureCollection。这与
to_geo_dict()的不同之处在于它是一个具有默认参数的属性,而不是一个方法。数据框的CRS未传递到输出,与
to_json()不同。示例
>>> from shapely.geometry import Point >>> d = {'col1': ['name1', 'name2'], 'geometry': [Point(1, 2), Point(2, 1)]} >>> gdf = geopandas.GeoDataFrame(d, crs="EPSG:4326") >>> gdf col1 geometry 0 name1 POINT (1 2) 1 name2 POINT (2 1)
>>> gdf.__geo_interface__ {'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)}