我刚安装得很整齐,基本的东西看起来很好。我开始在this教程中关注一个示例,以了解该库。
具体做法是:
>>> from shapely.wkt import loads
>>> g = loads('POINT (0.0 0.0)')
>>> g.buffer(1.0).area # 16-gon approx of a unit radius circle
3.1365484905459389
>>> g.buffer(1.0, 128).area # 128-gon approximation
3.1415138011443009
>>> g.buffer(1.0, 3).area # triangle approximation
3.0
>>> list(g.buffer(1.0, cap_style='square').exterior.coords)
[(1.0, 1.0), (1.0, -1.0), (-1.0, -1.0), (-1.0, 1.0), (1.0, 1.0)]
>>> g.buffer(1.0, cap_style='square').area
4.0
当我拨打g.buffer(1.0, cap_style='square')
时,我收到以下错误:
buf = list(shp.buffer(1.0, cap_style='square'))
File "/usr/lib64/python2.7/site-packages/shapely/geometry/base.py", line 538, in buffer
mitre_limit))
File "/usr/lib64/python2.7/site-packages/shapely/topology.py", line 78, in __call__
return self.fn(this._geom, *args)
ctypes.ArgumentError: argument 5: <type 'exceptions.TypeError'>: wrong type
阅读文档here我看到这个例子在shapely / geometry / base.py模块的注释中。但是我注意到cap_style参数的默认值是int(CAP_STYLE.round
)类型,而不是string。不确定这是否意味着什么。
有谁知道发生了什么事?
答案 0 :(得分:0)
看来你自己回答了你的问题:)
这确实是你提到的问题。 cap_style
键参数必须是整数。根据{{3}},只有以下值可用。
大写字母的样式由整数值指定:1(圆形),2 (平),3(平方)。这些值也由对象枚举 shapely.geometry.CAP_STYLE。