Discussion:
[Community] Shapely + 3D points
Marc
2011-03-01 08:45:04 UTC
Permalink
Hello,

first of all, thanks Sean for answering my previous mail. I did not
reply yet as I've been working on other projects, and I'm still not sure
what I can do to help (I'm not convinced I'm able to implement what you
proposed in the mail, even if I would really like).

I'm facing a different issue now and could not find any explanation by
reading the code or Google :)
p1 = Point(0,0,0)
print p1
POINT (0.0000000000000000 0.0000000000000000)
Why is my third coord ignored ? I can see that the 'coords' attribute
has the 3rd value, but it looks like it's being ignored by some routine
(for example, printing or exporting to wkt). The '_ndim' is correctly
set to 3, so as I understand, the 3rd value should be used... ?

I'm really sorry if this is documented somewhere.

Thanks,
Marc

PS: I'm using shapely 1.2.1 on ubuntu and have updated it to 1.2.8 from
Debian sid (I don't remember having this problem on my debian sid box)
Justin Bronn
2011-03-01 14:12:11 UTC
Permalink
Post by Marc
Why is my third coord ignored ? I can see that the 'coords' attribute
has the 3rd value, but it looks like it's being ignored by some routine
(for example, printing or exporting to wkt). The '_ndim' is correctly
set to 3, so as I understand, the 3rd value should be used... ?
The WKT writer in GEOS does not serialize 3D coordinates by default:

http://trac.osgeo.org/geos/browser/trunk/src/io/WKTWriter.cpp#L118

If you're adventurous, you can try enabling the PRINT_Z macro. GEOS
only supports exporting 3D information as EWKB/HEXEWKB.

-Justin
Marc
2011-03-01 20:11:52 UTC
Permalink
Post by Justin Bronn
Post by Marc
Why is my third coord ignored ? I can see that the 'coords' attribute
has the 3rd value, but it looks like it's being ignored by some routine
(for example, printing or exporting to wkt). The '_ndim' is correctly
set to 3, so as I understand, the 3rd value should be used... ?
http://trac.osgeo.org/geos/browser/trunk/src/io/WKTWriter.cpp#L118
If you're adventurous, you can try enabling the PRINT_Z macro. GEOS only
supports exporting 3D information as EWKB/HEXEWKB.
Thanks for your answer :)

Strange thing is that with stock Debian sid, it works as expected
without doing anything. I'll try to find what is causing this difference
in behavior (haven't seen any ref to PRINT_Z macro in debian package).

Cheers,
Marc
Marc
2011-03-03 09:54:59 UTC
Permalink
Post by Marc
Thanks for your answer :)
Strange thing is that with stock Debian sid, it works as expected
without doing anything. I'll try to find what is causing this
difference in behavior (haven't seen any ref to PRINT_Z macro in
debian package).
Hello again,

after some more digging, I've been able to find how to make things work.
First, I upgraded my python-gdal package from 1.6.3 (current Ubuntu) to
1.7.3 (current debian sid). I also upgraded all gdal-bin (1.7.3) and
created/installed libgdal1-1.7.0. This makes the .exportToWkt() method
correctly export the 3rd coord. But then, shapely.wkt.loads() does not
use this 3rd coord. So I recompiled the python-shapely from debian sid
(1.2.8) and now it works great.

I'm currently uploading these backported packages to my ppa, if it is of
any interest to anyone:

https://launchpad.net/~marc-poulhies/+archive/ppa

(I've also created packages for rtree, geojson & spatialindex)

Cheers,
Marc

Loading...