Hello!
I've been using Shapely for a few weeks, and I'm wondering if there is
a simpler way to access z values from Shapes (other than Points).
For instance, I use a lot of Polygons and right now, although they are
created with 3 dimensions, their rings seem to automatically get a
_ndim of 2 although they _do_ store the z (see example below). It gets
a bit contrived to get the value back (must force the _ndim to 3), but
since Shapely isn't meant to deal with 3d geometries I'm not sure if
this qualifies as a bug.
An example:
>>> from shapely.geometry import Point, Polygon
>>> p = Point(1., 1., 5.)
>>> print p.__geo_interface__
{'type': 'Point', 'coordinates': (1.0, 1.0, 5.0)} # Great!
>>> poly = Polygon(((1., 11., 20.),
... (11., 1., 20.),
... (1., -9., 20.),
... (-9., 1., 20.)))
>>> print poly.__geo_interface__
{'type': 'Polygon', 'coordinates': (((1.0, 11.0), (11.0, 1.0), (1.0, -9.0),
(-9.0, 1.0), (1.0, 11.0)),)}
>>> print poly._ndim
3
>>> print poly.has_z
True
>>> e = poly.exterior
>>> print e._ndim
2 # Hm...
>>> list(e.coords)
[(1.0, 11.0), (11.0, 1.0), (1.0, -9.0), (-9.0, 1.0), (1.0, 11.0)]
>>> e._ndim = 3
>>> list(e.coords)
[(1.0, 11.0, 20.0), (11.0, 1.0, 20.0), (1.0, -9.0, 20.0), (-9.0, 1.0, 20.0),
(1.0, 11.0, 20.0)] # Haha!
Ideally I'd love to be able to get z back from
<shape>.__geo_interface__, but that might be asking for too much :)
Still, I expected the rings to be returned with the correct number of
dimensions. Is there a simpler way to get z back?
Thank you for your time!
Regards,
Julie
_______________________________________________
Community mailing list
[email protected]
http://lists.gispython.org/mailman/listinfo/community