에서 기능 모음을 만드는 데, 내가 찾고 있어요 임시 파일없이 그것을 할 수있는 방법. 나는 geopandas.GeoDataFrame.from_feature()
을 사용하려고 시도했으나 단순한 다각형의 기능 모음에 대해서는 꽤 잘 작동했지만, Feature Collection
이 Polygons
과 MultiPolygons
인 경우 작동하지 못했습니다. 아래에서와 같이 생각하고 있었지만 아직 작동하지 않습니다.가 어떻게 <code>Polygons</code>과 <code>MultiPolygons</code>의 <code>Feature Collection</code>을하고 난 다음 geopandas.GeoDataFrame.from_file (tmp_json_file)와로드 먼저 임시 파일에 쓰기 위해 가지고 GeoJSON
features_collection = []
for feature in json_data['features']:
tmp_properties = {'id': feature['properties']['id']}
if is_multipolygon (feature):
tmp = Feature(geometry=MultiPolygon((feature['geometry']['coordinates'])), properties=tmp_properties)
else:
Feature(geometry=Polygon((feature['geometry']['coordinates'])), properties=tmp_properties)
features_collection.append(tmp)
collection = FeatureCollection(features_collection)
return geopandas.GeoDataFrame.from_features(collection['features'])
GeoJSON은 영토를 반환하는 API에서 가져온 것입니다 (일부 지역은 다중의 형식 다각형의 집합()에 의해 다른 하나의 폴리곤에 의해 모델화된다.
GeoJSON에 따라로 구성되어 : http://pastebin.com/PPdMUGkY
나는 위의 함수에서 다음과 같은 오류를 받고 있어요: 난 그냥 JSON을 공급하는 경우 나이를 위해
Traceback (most recent call last):
File "overlap.py", line 210, in <module>
print bdv_json_to_geodf(contours_bdv)
File "overlap.py", line 148, in json_to_geodf
return geopandas.GeoDataFrame.from_features(collection['features'])
File "/Library/Python/2.7/site-packages/geopandas/geodataframe.py", line 179, in from_features
d = {'geometry': shape(f['geometry'])}
File "/Library/Frameworks/GEOS.framework/Versions/3/Python/2.7/site-packages/shapely/geometry/geo.py", line 40, in shape
return MultiPolygon(ob["coordinates"], context_type='geojson')
File "/Library/Frameworks/GEOS.framework/Versions/3/Python/2.7/site-packages/shapely/geometry/multipolygon.py", line 64, in __init__
self._geom, self._ndim = geos_multipolygon_from_py(polygons)
File "/Library/Frameworks/GEOS.framework/Versions/3/Python/2.7/site-packages/shapely/geometry/multipolygon.py", line 138, in geos_multipolygon_from_py
N = len(ob[0][0][0])
TypeError: object of type 'float' has no len()
재현 가능한 예를 제공하십시오 (http://stackoverflow.com/help/mcve). 'json_data '란 무엇입니까? 이미 FeatureCollection 인 경우 FeatureCollection을 만드는 이유는 무엇입니까? GeoDataFrame.from_features'에 제공하면 어떤 오류가 발생합니까? – joris
예, 내 게시물을 편집했습니다. – kwn