You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
when I create the shapefile,such as:
w = shapefile.Writer(shapname)
w.field("name1", "C")
w.linez([data1])
w.record("cross1")
w.field("name2", "C")
w.linez([data2])
w.record("line1")
w.close()
Then I read the shapefile:
sf = shapefile.Reader(shapname)
datas = sf.shapes()
for data in datas:
points = data.points
x, y = zip(*points)
z = data.z
How to get the field name for data(x,y,z)?
The text was updated successfully, but these errors were encountered:
This yields shapeRecords, which have a record attribute, which has a really nice ._as_dict method. The keys of the dictionary that returns are the field names.
with shapefile.Reader(shapname) as sf:
for shaperec in sf.shapeRecords():
points = shaperec.shape.points
x, y = zip(*points)
z = shaperec.shape.z # I think, but haven't got a 3D shapefile right now to test this
record_dict = sr.record.as_dict()
fields = record_dict.keys()
values = record_dict.values()
What's your question?
when I create the shapefile,such as:
w = shapefile.Writer(shapname)
w.field("name1", "C")
w.linez([data1])
w.record("cross1")
w.field("name2", "C")
w.linez([data2])
w.record("line1")
w.close()
Then I read the shapefile:
sf = shapefile.Reader(shapname)
datas = sf.shapes()
for data in datas:
points = data.points
x, y = zip(*points)
z = data.z
How to get the field name for data(x,y,z)?
The text was updated successfully, but these errors were encountered: