我有生成shapefile的代码,但字段的数量取决于某些因素。目前,我在输入上测试它,我知道它产生了3个字段,所以有这个代码。
output = shapefile.Writer(shapefile.POINT)
for i in range(1,(input.fieldcount+1)):
fieldname = "field" + str(i)
output.field(fieldname,'C','40')
for i in range(len(output.item)):
output.point(input.item[i].x,input.item[i].y)
graphshp.record(input.field[0],input.field[1],input.field[2])但我想更改这一行:
graphshp.record(input.field[0],input.field[1],input.field[2])所以它不是硬编码的。
发布于 2012-03-12 06:35:27
每个the pyshp source
您可以提交一系列字段值,也可以提交字段名称和值的关键字参数。
要提交一系列字段值,您需要执行以下操作:
graphshp.record( *input.field )如果您感兴趣,Python的excellent documentation中包含了任意参数列表。
https://stackoverflow.com/questions/9659457
复制相似问题