我正在尝试使用 kartograph py 生成 svg 地图,如下所示:
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