您可能沒有正確嵌套部件列表。我假設你正在嘗試創建一個多部分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")