If the Python `zip` function is used to combine X and Y coordinates, the result
is a list of tuples:
X = [1, 5, 5, 3, 1]
Y = [5, 5, 1, 3, 1]
coors = zip(X, Y) # list of tuples
However, this object cannot be used by the shapefile.py module:
import shapefile
w = shapefile.Writer(shapefile.POLYGON)
w.field('MYFIELD','C')
w.poly([coors])
Traceback (most recent call last):
File "<interactive input>", line 1, in <module>
File "shapefile.py", line 684, in poly
point.append(0)
AttributeError: 'tuple' object has no attribute 'append'
To fix this, I've added a check to shapefile.py near line 679:
# Ensure point is list
if not isinstance(point, list):
point = list(point)
See attached patch. I've also removed trailing whitespace on various lines in
this patch.
Original issue reported on code.google.com by mwto...@gmail.com on 3 Mar 2011 at 12:04
Original issue reported on code.google.com by
mwto...@gmail.com
on 3 Mar 2011 at 12:04Attachments: