[vtkusers] data export problem

baiqi cheng sigurd.cbq425 at gmail.com
Wed Sep 26 00:30:34 EDT 2018


Dear All,

I'm trying to export a vtk into a csv file.
 however, it gives me an error message "ValueError: all the input array
dimensions except for the concatenation axis must match exactly."

my code is shown below. Can someone help me with this? I really appreciate
it.

import vtk from vtk.numpy_interface import dataset_adapter as dsa import
numpy as np from scipy import sparse import keras reader =
vtk.vtkUnstructuredGridReader() reader.SetFileName("1111.vtk")
reader.ReadAllFieldsOn() reader.Update() vtk_data = reader.GetOutput()
points = vtk_data.GetPoints() n_points = points. GetNumberOfPoints()
vtk_dataset_adapter = dsa.WrapDataObject(vtk_data) coords =
vtk_dataset_adapter.GetPoints() density =
vtk_dataset_adapter.PointData['density'] data_export =
np.column_stack((coords,density))

---------------------------------------------------------------------------ValueError
                               Traceback (most recent call
last)<ipython-input-13-e1f4e90953a9> in <module>()     18 density =
vtk_dataset_adapter.PointData['density']     19 ---> 20 data_export =
np.column_stack((coords,density))     21      22
E:\Anacondapython3.6\envs\mlbook\lib\site-packages\numpy\lib\shape_base.py
in column_stack(tup)    367             arr = array(arr, copy=False,
subok=True, ndmin=2).T    368         arrays.append(arr)--> 369
return _nx.concatenate(arrays, 1)    370     371 def dstack(tup):
ValueError: all the input array dimensions except for the
concatenation axis must match exactly


Regards,
Aaron
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://public.kitware.com/pipermail/vtkusers/attachments/20180926/d7156931/attachment.html>


More information about the vtkusers mailing list