Convert VTK ASCII to Binary to save space

I have a .vtk file (0.25 TB) n ASCII format which I visualize in ParaView. I like to transfer the data to my collaborators for which I would like to convert it into a binary format.

I tried to search through the internet and was unsuccessful in obtaining a solution.

Can anyone help me with this ?

Thanks.

If you are able to load it into ParaView, then you can easily save the data to a binary format through the File -> Save Data… menu item, then choose the VTK Legacy writer. Once you set the file name and click OK, an options dialog for the writer appears.

image

By default, the output will be binary, so you can click OK and you have now saved out a binary .vtk file.

You may also be interested in saving to the XML output file type that also supports binary encoding and compression with various compression algorithms. Those options are presented in the same dialog as above when you save to an XML format.

Thanks Cory.

The file is too large (0.25 TB) to be loaded into ParaView for visualization. Is there a way to do it using Python script ?

from paraview.simple import *
r = LegacyVTKReader( FileNames=['Yourfilename.vtk'] )
SaveData('Yourfilename_binary.vtk', proxy=r)

Should save as binary by default.

used from: https://stackoverflow.com/a/58209834

1 Like

The function SaveData() is not working with Paraview’s older versions (like 3.98.1). I found its implementation here and moved it to my code. How can I save my file as ASCII? Calling it like SaveData(filename, proxy=px, FileType='Ascii') is not working (it saves my files as binaries).