# set/get FieldData with numpy\_interface.dataset\_adapter

**URL:** https://discourse.vtk.org/t/set-get-fielddata-with-numpy-interface-dataset-adapter/4550
**Category:** Support
**Created:** [November 2, 2020, 10:48am UTC](https://discourse.vtk.org/t/set-get-fielddata-with-numpy-interface-dataset-adapter/4550 "2020-11-02T10:48:26Z")
**Posts on this page:** 1
**Showing post:** 5

<div class="post-metadata">

### Author: ![bistek](https://discourse.vtk.org/user_avatar/discourse.vtk.org/bistek/32/2344_2.png) [@bistek](https://discourse.vtk.org/u/bistek)
#### Post date: [November 3, 2020, 4:25pm UTC](https://discourse.vtk.org/t/set-get-fielddata-with-numpy-interface-dataset-adapter/4550/5 "2020-11-03T16:25:29Z")

</div>

I just got an answer on GitLab (thanks!):

[https://gitlab.kitware.com/vtk/vtk/-/issues/18042](https://gitlab.kitware.com/vtk/vtk/-/issues/18042)

I copy it here:

The string array (vtkStringArray) in VTK is not memory compatible with numpy string arrays so the numpy interface does not support it. You have to use vtkStringArray directly to add string arrays:

```auto
array = vtk.vtkStringArray()
array.SetName("foo")
array.SetNumberOfTuples(2)
arraySetValue(0, "test")
array.SetValue(1, "test2")
my_polydata_dsa.GetFieldData().AddArray(array)

```

After this, it is possible to retrieve the array with:

```auto
my_polydata_dsa.GetFieldData().keys()
>>> ['foo']

my_polydata_dsa.GetFieldData().values()
>>> [(vtkmodules.vtkCommonCore.vtkStringArray)00000257193E1048]

my_polydata_dsa.GetFieldData().values()[0].GetValue(1)
>>> 'text_2'

```

---

_[View the full topic](https://discourse.vtk.org/t/set-get-fielddata-with-numpy-interface-dataset-adapter/4550)._
