简体   繁体   English

shapely.geos.ReadingError:由于读取输入时的错误,无法创建几何体

[英]shapely.geos.ReadingError: Could not create geometry because of errors while reading input

I'm getting the error in the title when I try to use shapely.wkt.loads on the following input: 当我尝试在以下输入上使用shapely.wkt.loads时,我在标题中收到错误:

POLYGON((-93.577695846689437 40.813390731817726,-93.577674865779628 40.813444137603014,-93.577722549304582 40.8136196133706,-93.577945709640048 40.814004897950532,-93.5781135556297 40.814165115070466,-93.578243255589527 40.814229965262996,-93.578363418973865 40.814268111930119,-93.578405380213241 40.814252853305611,-93.578418731892242 40.814207077283442,-93.578376770009427 40.81411170971851,-93.578311920291867 40.814050674367543,-93.578300476322624 40.814008712491074,-93.578235626128318 40.813978195044577,-93.5779953002333 40.813646316512269,-93.577934265283389 40.813581466662242,-93.577924728143131 40.813535690301279,-93.577777862415886 40.813383102422016,-93.577695846689437 40.81339073181772))

Saving you the trouble of scrolling through all that, it's in WKT format. 省去了滚动所有这些的麻烦,它是WKT格式。 It's one of about 100 Polygons I'm reading in, and it's the only one throwing this error. 这是我正在阅读的大约100个多边形之一,而且它是唯一一个抛出这个错误的人。 To be clear, when I call: 要清楚,当我打电话:

p = loads('POLYGON((-93.577695846689437 40.813390731817726,-93.577674865779628 40.813444137603014,-93.577722549304582 40.8136196133706,-93.577945709640048 40.814004897950532,-93.5781135556297 40.814165115070466,-93.578243255589527 40.814229965262996,-93.578363418973865 40.814268111930119,-93.578405380213241 40.814252853305611,-93.578418731892242 40.814207077283442,-93.578376770009427 40.81411170971851,-93.578311920291867 40.814050674367543,-93.578300476322624 40.814008712491074,-93.578235626128318 40.813978195044577,-93.5779953002333 40.813646316512269,-93.577934265283389 40.813581466662242,-93.577924728143131 40.813535690301279,-93.577777862415886 40.813383102422016,-93.577695846689437 40.81339073181772))')

I get the error: shapely.geos.ReadingError: Could not create geometry because of errors while reading input. 我收到错误: shapely.geos.ReadingError: Could not create geometry because of errors while reading input.

I even went through the trouble of parsing it up into regular shapely.geometry.Polygon format. 我甚至经历了将其解析为常规shapely.geometry.Polygon格式的麻烦。 Then, it works fine. 然后,它工作正常。 But I'd rather not clutter code with annoying string parsing (and an ugly try/except). 但是我宁愿用烦人的字符串解析(以及丑陋的尝试/除外)来使代码混乱。 And, of course, the shapely/wky.py file tells me absolutely nothing... If anyone knows what's going on/how to fix it, I'd appreciate it. 而且,当然,匀称/ wky.py文件绝对没有告诉我......如果有人知道发生了什么/如何解决它,我会很感激。 Thanks! 谢谢!

The geometry contains non-closed rings. 几何包含非闭环。 Looking at the first and last coordinate: 查看第一个和最后一个坐标:

  • -93.577695846689437 40.813390731817726
  • -93.577695846689437 40.81339073181772

Adding 6 at the end of the last coordinate string will make the two equal, and the outer shell a closed linear ring required to make a polygon. 在最后一个坐标字符串的末尾添加6将使两者相等,并且外壳是制作多边形所需的闭合线性环。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM