# Reading VTK files into Julia?

**URL:** <https://discourse.julialang.org/t/reading-vtk-files-into-julia/86420>\
**Category:** General Usage\
**Created:** [August 27, 2022, 7:59am UTC](https://discourse.julialang.org/t/reading-vtk-files-into-julia/86420 "2022-08-27T07:59:48Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ahmed\_Salih](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ahmed_salih/32/206579_2.png) [@Ahmed\_Salih](https://discourse.julialang.org/u/Ahmed_Salih)\
**Post date:** [August 27, 2022, 7:59am UTC](https://discourse.julialang.org/t/reading-vtk-files-into-julia/86420/1 "2022-08-27T07:59:48Z")

</div>

Hello!

Is there any Julia library which wraps the VTK library in such a way that both legacy and new vtk file formats can be read?

The top search item is “ReadVTK.jl”, which supposedly can read the new XML vtk file format, but not the legacy formats - I need to be able to do both.

Kind regards

---

<div class="post-metadata">

**Author:** ![vavrines](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/vavrines/32/8024_2.png) [@vavrines](https://discourse.julialang.org/u/vavrines)\
**Post date:** [August 28, 2022, 2:15pm UTC](https://discourse.julialang.org/t/reading-vtk-files-into-julia/86420/2 "2022-08-28T14:15:23Z")

</div>

You can use Python package [meshio](https://github.com/nschloe/meshio). I have a Julia wrapper [FiniteMesh.jl](https://github.com/vavrines/FiniteMesh.jl) built on top of it.

---

<div class="post-metadata">

**Author:** ![Ahmed\_Salih](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ahmed_salih/32/206579_2.png) [@Ahmed\_Salih](https://discourse.julialang.org/u/Ahmed_Salih)\
**Post date:** [August 28, 2022, 2:32pm UTC](https://discourse.julialang.org/t/reading-vtk-files-into-julia/86420/3 "2022-08-28T14:32:43Z")

</div>

Great thanks!

And it is correctly understood that even though it is based on Python, I don’t need to install anything directly? Just “using FiniteMesh” and then it should be fine?

Kind regards

---

<div class="post-metadata">

**Author:** ![Ahmed\_Salih](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ahmed_salih/32/206579_2.png) [@Ahmed\_Salih](https://discourse.julialang.org/u/Ahmed_Salih)\
**Post date:** [August 28, 2022, 2:37pm UTC](https://discourse.julialang.org/t/reading-vtk-files-into-julia/86420/4 "2022-08-28T14:37:58Z")

</div>

Unfortunately does not work for me:

```julia
Only VTK 'UNSTRUCTURED_GRID', 'STRUCTURED_POINTS', 'STRUCTURED_GRID', 'RECTILINEAR_GRID' supported (not POLYDATA).

```

Didn’t think that POLYDATA would be any different

Thanks for the suggestion once again

Kind regards

---

<div class="post-metadata">

**Author:** ![vavrines](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/vavrines/32/8024_2.png) [@vavrines](https://discourse.julialang.org/u/vavrines)\
**Post date:** [August 28, 2022, 2:42pm UTC](https://discourse.julialang.org/t/reading-vtk-files-into-julia/86420/5 "2022-08-28T14:42:16Z")

</div>

Okay, then I would suggest the official vtk library for Python [vtk · PyPI](https://pypi.org/project/vtk/).  
Then you will need to use PyCall or PythonCall.jl.

---

<div class="post-metadata">

**Author:** ![juliohm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juliohm/32/215266_2.png) [@juliohm](https://discourse.julialang.org/u/juliohm)\
**Post date:** [August 28, 2022, 5:12pm UTC](https://discourse.julialang.org/t/reading-vtk-files-into-julia/86420/6 "2022-08-28T17:12:07Z")

</div>

Give a try to

> **[GitHub - JuliaVTK/ReadVTK.jl: Julia package for reading VTK XML files](https://github.com/JuliaVTK/ReadVTK.jl)**
>
> Julia package for reading VTK XML files. Contribute to JuliaVTK/ReadVTK.jl development by creating an account on GitHub.

---

<div class="post-metadata">

**Author:** ![Ahmed\_Salih](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ahmed_salih/32/206579_2.png) [@Ahmed\_Salih](https://discourse.julialang.org/u/Ahmed_Salih)\
**Post date:** [August 28, 2022, 5:15pm UTC](https://discourse.julialang.org/t/reading-vtk-files-into-julia/86420/7 "2022-08-28T17:15:55Z")

</div>

Doesn’t work either, returns:

```julia
VTKFile("PartBound_0000.vtk")
ERROR: bad VTK file format (found legacy format; only VTK XML files are currently supported)

```

So properly due to it being a polydata legacy VTK file, not based on XML 😕

Kind regards

---

<div class="post-metadata">

**Author:** ![juliohm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juliohm/32/215266_2.png) [@juliohm](https://discourse.julialang.org/u/juliohm)\
**Post date:** [August 28, 2022, 5:17pm UTC](https://discourse.julialang.org/t/reading-vtk-files-into-julia/86420/8 "2022-08-28T17:17:42Z")

</div>

Maybe you can load the file into Visit or Paraview and then ask to save again into the new format?

---

<div class="post-metadata">

**Author:** ![Ahmed\_Salih](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ahmed_salih/32/206579_2.png) [@Ahmed\_Salih](https://discourse.julialang.org/u/Ahmed_Salih)\
**Post date:** [August 28, 2022, 5:19pm UTC](https://discourse.julialang.org/t/reading-vtk-files-into-julia/86420/9 "2022-08-28T17:19:33Z")

</div>

Yep, perhaps I can make a converter function which does it automatically for me in Paraview. Software I am using outputs legacy VTK format presumably because it was developed in ~2010 and a low priority to update 🙂

Thanks for the help everyone
