【问题标题】:Confused about python shapely exception ctypes.ArgumentError对 python 形状异常 ctypes.ArgumentError 感到困惑
【发布时间】:2016-10-12 21:17:45
【问题描述】:

我刚刚安装得体,基本的东西看起来还不错。我开始按照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 模块的 cmets 中。但是我注意到 cap_style 参数的默认值是 int (CAP_STYLE.round) 类型而不是字符串。不确定这是否意味着什么。

有人知道发生了什么吗?

【问题讨论】:

    标签: python-2.7 shapely


    【解决方案1】:

    看来你自己回答了你的问题:) 确实是你说的问题。 cap_style 键参数必须是整数。并且根据shapely documentation,只有以下值可用。

    大写的样式由整数值指定:1(圆形)、2 (平面),3(方形)。这些值也由对象枚举 shapely.geometry.CAP_STYLE。

    【讨论】:

      猜你喜欢
      • 2021-07-19
      • 1970-01-01
      • 2020-12-09
      • 1970-01-01
      • 1970-01-01
      • 2013-08-20
      • 2023-03-17
      • 2014-12-31
      • 2011-02-04
      相关资源
      最近更新 更多