# Convert VTKArray to numpy array

**URL:** https://discourse.paraview.org/t/convert-vtkarray-to-numpy-array/10036
**Category:** ParaView Support
**Tags:** vtk
**Created:** [July 21, 2022, 12:59pm UTC](https://discourse.paraview.org/t/convert-vtkarray-to-numpy-array/10036 "2022-07-21T12:59:30Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![PhDFlo](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/p/a88e4f/32.png) [@PhDFlo](https://discourse.paraview.org/u/PhDFlo)
#### Post date: [July 21, 2022, 12:59pm UTC](https://discourse.paraview.org/t/convert-vtkarray-to-numpy-array/10036/1 "2022-07-21T12:59:31Z")

</div>

Hello all,

I want to extract the points and data of a slice from my simulation to write it into an ASCII file. For simplicity of further representation I converted my data to point data (cellDatatoPointData1) so that I have a data value for every point of the slice. I managed to do it but i cannot convert the data of the VTKArray into simple python float. I have seen many things on the internet to convert VTKDataArray to numpy array, but unfortunately it does not work for the VTKArray type. I can see the value when I print slice\_data[var] but I cannot convert it into float. Does anyone know what I’m missing to convert my VTK arrays ?

My script is the following:

```auto
from paraview import servermanager as sm
from paraview.vtk.numpy_interface import dataset_adapter as dsa
vtk_data = sm.Fetch(cellDatatoPointData1)
vtk_data = dsa.WrapDataObject(vtk_data)

# Coordinates extraction
slice_points = vtk_data.GetPoints()

# Data extraction
slice_data = dict()
for var in Vars:
    slice_data[var] = vtk_data.GetPointData[var]

size = slice_data[var].GetSize()

...

# Writing X, Y, Z, var
for i in range(size):
    print(vtkToNumpy(slice_points[i]))
    Str_Val = " {0: 1.12e}".format(slice_points[i][0])
    Str_Val += " {0: 1.12e}".format(slice_points[i][1])
    Str_Val += " {0: 1.12e}".format(slice_points[i][2])
    Str_Val += " {0: 1.12e}".format(slice_data[var][i])

```
