2016-02-04 176 views
1

我的线条正在连接,尽管我没有将它们设置为多边形。Pyshp:PolyLineZ绘图在我的线条之间绘制线条

我基于我的脚本pyshp包。

我的剧本是这样的:

w=Shapefile.Writer() 
#shapetype 11 is a polylineZ 
w.poly(parts=[listOfCoordinates], shapeType = 11) 
w.record(this,and,that) 
w.save(file) 

的问题是,当我产生多聚的QGIS我打开它们在吸引它们之间的线。 实施例:

一条线从A转到B.

另一条线由C变为d

出于某种原因QGIS平B和C.我认为这具有与做之间的线形状文件的pyshp处理。更具体的'bbox'字段,它为每个形状设置线索。

该解决方案将使B和C之间的界线消失。

回答

2

您可能没有正确嵌套部件列表。我假设你正在尝试创建一个多部分polylineZ shapefile,其中的行共享一个dbf记录。此外,polylineZ类型实际上是13而不是11.

以下代码创建两个形状文件,每个文件有三条平行线。在这个例子中,我并不打扰Z坐标。第一个shapefile是一个多部分,我假设你正在创建。第二个shapefile为每行提供自己的记录。两者都使用相同的线条几何形状。

import shapefile 

# Create a polylineZ shapefile writer 
w = shapefile.Writer(shapeType = 13) 
# Create a field called "Name" 
w.field("NAME") 
# Create 3 parallel, 2-point lines 
line_A = [[5, 5], [10, 5]] 
line_B = [[5, 15], [10, 15]] 
line_C = [[5, 25], [10, 25]] 
# Write all 3 as a multi-part shape 
# sharing one record 
w.poly(parts=[line_A, line_B, line_C]) 
# Give the shape a name attribute 
w.record("Multi Example") 
# save 
w.save("multi_part") 

# Create another polylineZ shapefile writer 
w = shapefile.Writer(shapeType = 13) 
# Create a field called "Name" 
w.field("NAME") 
# This time write each line separately 
# with its own dbf record 
w.poly(parts=[line_A]) 
w.record("Line A") 
w.poly(parts=[line_B]) 
w.record("Line B") 
w.poly(parts=[line_C]) 
w.record("Line C") 
# Save 
w.save("single_parts")