pyntcloud
pyntcloud copied to clipboard
ply-compatible float64 types
Description
.ply
files were not written with "double" coordinates even though the xyz coordinates columns were in float64 format.
I was dealing with ply files in geospatial context and required to save a .ply
file. I hit this issue, so here is the PR.
This seems to have been a pain for the community:
-
As far as I remember, float64 caused the export to binary formats (i.e ply) to fail. https://github.com/daavoo/pyntcloud/issues/146#issuecomment-369141788
-
The problem I found was that even though I could export/import PLY files with float64 values inside pyntcloud, those files weren't correctly loaded in other programs such as Three.js or CloudCompare so I just decided to force the float32 conversion because any of the logic in pyntcloud was affected by that. https://github.com/daavoo/pyntcloud/issues/146#issuecomment-369179245
- https://github.com/daavoo/pyntcloud/issues/234
Proposed changes
-
make float64 compatible with ply files (written ply files with float64 (double) coordinates can be opened by cloudcompare)
-
make property_format mapping better (written ply files can now exploit all the scalar data types a .ply file can support)
-
try downcasting column if column dtype is not compatible with PLY specification
-
fix most of flake8 issues (1 remaining)
-
backward compatible with https://github.com/daavoo/pyntcloud/issues/309
References :
- numpy built-in scalar types : https://numpy.org/devdocs/reference/arrays.scalars.html#built-in-scalar-types
- ply format description : http://paulbourke.net/dataformats/ply/
Was wondering if the downcast propagation should be done on a copy of the points dataframe instead of the points dataframe itself.
If true, we should add points = points.copy()
at the beginning of pyntcloud.io.ply.write_ply
function.