如何正確將shapefile轉換爲MultiPolygon?我得到試圖把shape文件成的MultiPolygon時生成以下錯誤...Python在參數中遇到的無效類型
.401 395951.4, 238087.5 395958.5, 238086.5 395963, 238086.3 395968.2, 238087.3 395973, 238090.7 395980.6, 238094.2 395989.2, 238101 395993.2, 238107.7 395994.1, 238114 395993.8, 238121.3 395992.6, 238131.6 395988.6, 238146.9 395978.2, 238184.401 395960.9, 238196.6 395958.4, 238203.1 395956.801, 238214.599 395953.4)))
Traceback (most recent call last):
File "geo.py", line 25, in <module>
Multi = MultiPolygon([pol['geometry'] for pol in fiona.open(file)])
File "/Users/user/Documents/workspace/env/lib/python3.4/site-packages/django/contrib/gis/geos/collections.py", line 38, in __init__
self._check_allowed(init_geoms)
File "/Users/user/Documents/workspace/env/lib/python3.4/site-packages/django/contrib/gis/geos/mutable_list.py", line 261, in _check_allowed
raise TypeError('Invalid type encountered in the arguments.')
file = 'NUTS1_DEC_2008_EW_BFE.shp'
代碼錯誤:
from shapely.geometry import shape
c = fiona.open(file)
pol = c.next()
geom = shape(pol['geometry'])
Multi = MultiPolygon([pol['geometry'] for pol in fiona.open(file)])
那就是我剛剛嘗試的(參見上面的更新) – Prometheus