You can extract point coordinates more compactly and without the extra PointWrangle using the following:
P = numpy.reshape(geometry.pointFloatAttribValues(“P”), (-1, 3))
Performance is roughly the same as the video, since either way you are converting every point coordinate into a sequence of Python floats prior before converting them again into a numpy array.
If you want greater efficiency at the expense of legibility, the following avoids the intermediate conversion into Python objects:
P = numpy.frombuffer(geometry.pointFloatAttribValuesAsString(“P”), dtype=numpy.float32).reshape(-1, 3)
On my machine, converting 10M points took 4.25s with the former approach, 0.24s with the latter.
Mo:
You can extract point coordinates more compactly and without the extra PointWrangle using the following:
P = numpy.reshape(geometry.pointFloatAttribValues(“P”), (-1, 3))
Performance is roughly the same as the video, since either way you are converting every point coordinate into a sequence of Python floats prior before converting them again into a numpy array.
If you want greater efficiency at the expense of legibility, the following avoids the intermediate conversion into Python objects:
P = numpy.frombuffer(geometry.pointFloatAttribValuesAsString(“P”), dtype=numpy.float32).reshape(-1, 3)
On my machine, converting 10M points took 4.25s with the former approach, 0.24s with the latter.
Cheers,
Tim
Amazing! Thanks so much for the info. Especially that sped up version looks lovely!
Cheers, Mo