我有一个多边形的特征集合,我必须先把它写在一个临时文件中然后加载它geopandas.GeoDataFrame.from_file(tmp_json_file)
,有没有办法不写临时文件而只GeoDataFrame
从GeoJSON
对象创建?
问问题
8225 次
1 回答
21
您可以为此使用该GeoDataFrame.from_features()
功能。一个小例子(假设你有一个 geojson FeatureCollection):
In [1]: from geojson import Feature, Point, FeatureCollection
In [2]: my_feature = Feature(geometry=Point((1.6432, -19.123)), properties={"country": "Spain"})
In [3]: my_other_feature = Feature(geometry=Point((-80.234, -22.532)), properties={'country': 'Brazil'})
In [4]: collection = FeatureCollection([my_feature, my_other_feature])
In [6]: import geopandas
In [7]: geopandas.GeoDataFrame.from_features(collection['features'])
Out[7]:
country geometry
0 Spain POINT (1.6432 -19.123)
1 Brazil POINT (-80.234 -22.532)
于 2016-06-09T19:46:14.423 回答