0
我試圖用kartograph PY如下生成一個SVG地圖:kartograph未知形狀類型(25)
from kartograph import Kartograph
K = Kartograph()
config ={"layers": {"mylayer": {"src": "42MEE250GC_SIR.shp"}} }
K.generate(config, outfile='mymap.svg')
而且我得到這個錯誤:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "c:\python27\lib\site-packages\kartograph.py-0.6.8-py2.7.egg\kartograph\k
artograph.py", line 46, in generate
_map = Map(opts, self.layerCache, format=format)
File "c:\python27\lib\site-packages\kartograph.py-0.6.8-py2.7.egg\kartograph\m
ap.py", line 48, in __init__
me.proj = me._init_projection()
File "c:\python27\lib\site-packages\kartograph.py-0.6.8-py2.7.egg\kartograph\m
ap.py", line 88, in _init_projection
map_center = self.__get_map_center()
File "c:\python27\lib\site-packages\kartograph.py-0.6.8-py2.7.egg\kartograph\m
ap.py", line 140, in __get_map_center
features = self._get_bounding_geometry()
File "c:\python27\lib\site-packages\kartograph.py-0.6.8-py2.7.egg\kartograph\m
ap.py", line 257, in _get_bounding_geometry
charset=layer.options['charset']
File "c:\python27\lib\site-packages\kartograph.py-0.6.8-py2.7.egg\kartograph\l
ayersource\shplayer.py", line 121, in get_features
geom = shape2geometry(shp, ignore_holes=ignore_holes, min_area=min_area, bbo
x=bbox, proj=self.proj)
File "c:\python27\lib\site-packages\kartograph.py-0.6.8-py2.7.egg\kartograph\l
ayersource\shplayer.py", line 159, in shape2geometry
raise KartographError('unknown shape type (%d)' % shp.shapeType)
kartograph.errors.KartographError: ←[0;31;40mKartograph-Error:←[0m unknown shape
type (25)
查看源Kartograph的代碼我們有這個:
if shp.shapeType in (5, 15): # multi-polygon
geom = shape2polygon(shp, ignore_holes=ignore_holes, min_area=min_area)
elif shp.shapeType == 3: # line
geom = points2line(shp)
else:
raise KartographError('unknown shape type (%d) in shapefile %s' % (shp.shapeType, self.shpSrc))
return geom
有人可以幫助我嗎?
我在下面嘗試了這個,我得到了另一個錯誤。
if shp.shapeType == 25:
return None
錯誤:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "c:\python27\lib\site-packages\kartograph.py-0.6.8-py2.7.egg\kartograph\k
artograph.py", line 46, in generate
_map = Map(opts, self.layerCache, format=format)
File "c:\python27\lib\site-packages\kartograph.py-0.6.8-py2.7.egg\kartograph\m
ap.py", line 50, in __init__
me.bounds_poly = me._init_bounds()
File "c:\python27\lib\site-packages\kartograph.py-0.6.8-py2.7.egg\kartograph\m
ap.py", line 205, in _init_bounds
raise KartographError('no features found for calculating the map bounds')
kartograph.errors.KartographError: ←[0;31;40mKartograph-Error:←[0m no features f
ound for calculating the map bounds
未生成mymap.svg – luckasx
我的錯誤,我的意思是什麼輸入文件? –
輸入文件是從這裏獲得的巴西國家地圖:ftp://geoftp.ibge.gov.br/malhas_digitais/municipio_2010/sc.zip – luckasx