# Counter-intuitive results for min/max spatial dimension of a data set

**URL:** <https://discourse.vtk.org/t/counter-intuitive-results-for-min-max-spatial-dimension-of-a-data-set/16159>\
**Category:** Development\
**Created:** [November 25, 2025, 8:17pm UTC](https://discourse.vtk.org/t/counter-intuitive-results-for-min-max-spatial-dimension-of-a-data-set/16159 "2025-11-25T20:17:10Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![user27182](https://discourse.vtk.org/user_avatar/discourse.vtk.org/user27182/32/10104_2.png) [@user27182](https://discourse.vtk.org/u/user27182)\
**Post date:** [November 25, 2025, 8:17pm UTC](https://discourse.vtk.org/t/counter-intuitive-results-for-min-max-spatial-dimension-of-a-data-set/16159/1 "2025-11-25T20:17:10Z")

</div>

I tried using the new `GetMinSpatialDimension`/`GetMaxSpatialDimension` members from VTK 9.5, but it returns results that seem counter-intuitive. E.g. for datasets without cells, the following prints `(3, 0)` as the min/max spatial dimensions respectively, but I would have expected the opposite, i.e. `(0, 3)` as the min/max, where min \<= max.

```py
import vtk

# Try PointSet
ps = vtk.vtkPointSet()
print(ps.GetMinSpatialDimension()) # 3
print(ps.GetMaxSpatialDimension()) # 0

# Try PolyData with no cells
poly = vtk.vtkPolyData()
points = vtk.vtkPoints()
points.InsertNextPoint(0.0, 0.0, 0.0)
poly.SetPoints(points)
print(poly.GetMinSpatialDimension()) # 3
print(poly.GetMaxSpatialDimension()) # 0

# Try PolyData with vertex cell
verts = vtk.vtkCellArray()
verts.InsertNextCell(1)
verts.InsertCellPoint(0)
poly.SetVerts(verts)
print(poly.GetMinSpatialDimension()) # 0
print(poly.GetMaxSpatialDimension()) # 0

```

Also, I understand that the implementation may just iterate over cells and return the spatial dimensions of these cells, but this can result in misleading dimensions if multiple 2D cells span 3 dimensions. E.g. a 3D cube is reported to have spatial dimensions of 2:

```py
import vtk
source = vtk.vtkCubeSource()
source.Update()
poly = source.GetOutput()

print(poly.GetMinSpatialDimension()) # 2
print(poly.GetMaxSpatialDimension()) # 2
print(poly.GetBounds()) # (-0.5, 0.5, -0.5, 0.5, -0.5, 0.5)

```

Since `PolyData` cannot have 3D cells, this seems to suggest that `PolyData` will never have max spatial dimensions \> 2, even if the `PolyData` geometry itself spans three dimensions? Is this the expected output from this method? And, if this is the case, shouldn’t `PointSet` always return min/max dimensions of `0`, since all the points are effectively like 0D vertex cells?

---

<div class="post-metadata">

**Author:** ![dgobbi](https://discourse.vtk.org/user_avatar/discourse.vtk.org/dgobbi/32/18_2.png) [@dgobbi](https://discourse.vtk.org/u/dgobbi)\
**Post date:** [November 26, 2025, 1:10am UTC](https://discourse.vtk.org/t/counter-intuitive-results-for-min-max-spatial-dimension-of-a-data-set/16159/2 "2025-11-26T01:10:52Z")

</div>

I’m wondering why these methods weren’t called `GetMinCellDimensionality()` and `GetMaxCellDimensionality()`, which would have made the meaning much clearer.

As for the min=3 and max=0, I’m sure that’s just how “min” and “max” computations were implemented, i.e. how they were initialized before the loop through the cells. I agree that it’s a counterintuitive result.

@spyridon97

---

<div class="post-metadata">

**Author:** ![spyridon97](https://discourse.vtk.org/user_avatar/discourse.vtk.org/spyridon97/32/7069_2.png) [@spyridon97](https://discourse.vtk.org/u/spyridon97)\
**Post date:** [November 26, 2025, 2:12am UTC](https://discourse.vtk.org/t/counter-intuitive-results-for-min-max-spatial-dimension-of-a-data-set/16159/3 "2025-11-26T02:12:22Z")

</div>

i wanted the exact same names as you but an internal poll resulted in these names. we should have made the poll public.

---

<div class="post-metadata">

**Author:** ![dgobbi](https://discourse.vtk.org/user_avatar/discourse.vtk.org/dgobbi/32/18_2.png) [@dgobbi](https://discourse.vtk.org/u/dgobbi)\
**Post date:** [November 26, 2025, 4:53am UTC](https://discourse.vtk.org/t/counter-intuitive-results-for-min-max-spatial-dimension-of-a-data-set/16159/4 "2025-11-26T04:53:10Z")

</div>

Polls in general aren’t a great way to decide things in software engineering, better to argue things out so that everyone understands the reasoning behind the available choices. Then hopefully one choice becomes clear to everyone, and if it does end up having to go to a vote, people have at least properly considered each option.
