# Creating a simple polyline VTKHDF

**URL:** https://discourse.vtk.org/t/creating-a-simple-polyline-vtkhdf/13828
**Category:** Support
**Created:** [May 1, 2024, 5:29pm UTC](https://discourse.vtk.org/t/creating-a-simple-polyline-vtkhdf/13828 "2024-05-01T17:29:53Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Nikolaos\_Beratlis](https://discourse.vtk.org/user_avatar/discourse.vtk.org/nikolaos_beratlis/32/8816_2.png) [@Nikolaos\_Beratlis](https://discourse.vtk.org/u/Nikolaos_Beratlis)
#### Post date: [May 1, 2024, 5:29pm UTC](https://discourse.vtk.org/t/creating-a-simple-polyline-vtkhdf/13828/1 "2024-05-01T17:29:53Z")

</div>

I have created a simple legacy VTK for a bunch of lines as shown below:

```auto
# vtk DataFile Version 3.0
vtk output
ASCII
DATASET POLYDATA
POINTS 4 float
0 0 0
1 1 0
1 2 0
2 0 0
LINES 2 8
3 0 1 3
3 4 2 0

```

I want to create the same geometry in VTKHDF (using Fortran code). I read through the example “test\_poly\_data.hdf” but i am confused as to when to create a group or a dataset or an attribute, some datasets in the example are within some groups and other datasets don’t belong to any group. So far I was able to create the header of VTKHDF

```auto
HDF5 "file.hdf" {
GROUP "/" {
   GROUP "VTKHDF" {
      ATTRIBUTE "Type" {
         DATATYPE H5T_STRING {
            STRSIZE 9;
            STRPAD H5T_STR_NULLTERM;
            CSET H5T_CSET_ASCII;
            CTYPE H5T_C_S1;
         }
         DATASPACE SCALAR
         DATA {
         (0): "PolyData"
         }
      }
      ATTRIBUTE "Version" {
         DATATYPE H5T_STD_I32LE
         DATASPACE SIMPLE { ( 2 ) / ( 2 ) }
         DATA {
         (0): 2, 2
         }
      }
   }
}
}

```

Do I need to create a stand alone dataset called “Points” next? How do I create the lines?

---

<div class="post-metadata">

### Author: ![Nikolaos\_Beratlis](https://discourse.vtk.org/user_avatar/discourse.vtk.org/nikolaos_beratlis/32/8816_2.png) [@Nikolaos\_Beratlis](https://discourse.vtk.org/u/Nikolaos_Beratlis)
#### Post date: [May 1, 2024, 6:53pm UTC](https://discourse.vtk.org/t/creating-a-simple-polyline-vtkhdf/13828/2 "2024-05-01T18:53:43Z")

</div>

I created the following hdf5 file:

```auto
HDF5 "file.hdf" {
GROUP "/" {
   DATASET "LINES" {
      DATATYPE H5T_STD_I32LE
      DATASPACE SIMPLE { ( 2, 2 ) / ( 2, 2 ) }
      DATA {
      (0,0): 1, 3,
      (1,0): 2, 4
      }
   }
   DATASET "POINTS" {
      DATATYPE H5T_IEEE_F32LE
      DATASPACE SIMPLE { ( 4, 3 ) / ( 4, 3 ) }
      DATA {
      (0,0): 1.2, 4.5, 1,
      (1,0): 6, 2.3, 5,
      (2,0): 8, 5, 3.4,
      (3,0): 6, 9, 3
      }
   }
   GROUP "VTKHDF" {
      ATTRIBUTE "Type" {
         DATATYPE H5T_STRING {
            STRSIZE 9;
            STRPAD H5T_STR_NULLTERM;
            CSET H5T_CSET_ASCII;
            CTYPE H5T_C_S1;
         }
         DATASPACE SCALAR
         DATA {
         (0): "PolyData"
         }
      }
      ATTRIBUTE "Version" {
         DATATYPE H5T_STD_I32LE
         DATASPACE SIMPLE { ( 2 ) / ( 2 ) }
         DATA {
         (0): 2, 2
         }
      }
   }
}
}

```

It contains a dataset named “POINTS” and another one named “LINES” similar to the legacy VTK file. But Paraview 5.12.0 can’t read it. A pop-up window appears called “Open Data Wtih…” with the default option ADIOS2VTXReader. I click OK and Paraview crashes.

---

<div class="post-metadata">

### Author: ![geoffw](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/g/898d66/32.png) [@geoffw](https://discourse.vtk.org/u/geoffw)
#### Post date: [May 2, 2024, 7:38pm UTC](https://discourse.vtk.org/t/creating-a-simple-polyline-vtkhdf/13828/3 "2024-05-02T19:38:28Z")

</div>

Can you find an example of the file that loads successfully and just compare the formats?

---

<div class="post-metadata">

### Author: ![lgivord](https://discourse.vtk.org/user_avatar/discourse.vtk.org/lgivord/32/3543_2.png) [@lgivord](https://discourse.vtk.org/u/lgivord)
#### Post date: [May 3, 2024, 6:19am UTC](https://discourse.vtk.org/t/creating-a-simple-polyline-vtkhdf/13828/4 "2024-05-03T06:19:18Z")

</div>

Hello @Nikolaos_Beratlis,

There is complete documentation about the file format which explain what you’ll need to create in term of groups, datasets and attributes here: [VTK File Formats - VTK documentation](https://docs.vtk.org/en/latest/design_documents/VTKFileFormats.html#poly-data)

You can also check this repository which contains several python scripts to generate valid vtkhdf file, sadly the script for polydata is a bit complex but it can help you: [https://gitlab.kitware.com/keu-public/vtkhdf/vtkhdf-scripts](https://gitlab.kitware.com/keu-public/vtkhdf/vtkhdf-scripts)
