I am trying to parse an input shapefile which consists of multiple polygons and want to create a new shapefile from this with added z values. Each polygon of the input shapefile is defined by multiple points, whereas each of these is defined by an x and y coordinate.
I am creating a new shapefile with x, y (simply copied from input shapefile) and z coordinates like so:
s = shapefile.Writer()
s.autoBalance = 1
s.shapeType = 15 // PolygonZ
pointlist = [[12345.123, 45678.123, 10.0], [23456.123, 34567.123, 10.0]]
s.poly(shapeType=s.shapeType, parts=[pointlist])
s.save("test.shp")
But now when I want to read this created shapefile I can't see the defined z values:
s = shapefile.Reader("test.shp")
print(s.shapes()[0].points) // [[12345.123, 45678.123]]
What am I missing that the z values aren't included? I have also tried to define the polygon with at least 4 points (where the last point is identical to the first one) – exactly like the docs are stating to do this, but this didn't help either.
When I am trying to read the z value of the first point of a polygon with QGIS I can easily see my specified values:
z(start_point($geometry)) // 10
Best Answer
If you examine GeospatialPython.com: Working with Elevation Values in Shapefiles (the blog of Joel Lawhead, creator of the Pyshp module)
From the supplied example: