# How to generate a triangulation with the correct orientation?

**URL:** https://discourse.vtk.org/t/how-to-generate-a-triangulation-with-the-correct-orientation/9599
**Category:** Support
**Tags:** python
**Created:** [October 13, 2022, 3:58pm UTC](https://discourse.vtk.org/t/how-to-generate-a-triangulation-with-the-correct-orientation/9599 "2022-10-13T15:58:06Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![llobera](https://discourse.vtk.org/user_avatar/discourse.vtk.org/llobera/32/5540_2.png) [@llobera](https://discourse.vtk.org/u/llobera)
#### Post date: [October 13, 2022, 3:58pm UTC](https://discourse.vtk.org/t/how-to-generate-a-triangulation-with-the-correct-orientation/9599/1 "2022-10-13T15:58:06Z")

</div>

I have the following code (see below) where:

l,r,t,b are the coordinate bounds of a numpy array Z of size nrows x ncols that contains elevation data

```auto
x =np.linspace(l, r, ncols)
y =np.linspace(t, b, nrows)

X,Y = np.meshgrid(x,y)

data = np.column_stack((X.ravel(), Y.ravel(), Z.ravel()))

z_values = vtkFloatArray()

# create an object array of grid points 
points = vtkPoints()
for x, y, z in data:
    points.InsertNextPoint(x,y,0) # InsertNextPoint(x,y,z)
    z_values.InsertNextValue(z)

# add the grid points to a polydata object
polydata = vtkPolyData()
polydata.SetPoints(points)
polydata.GetPointData().SetScalars(z_values)

# triangulate the grid points
interp_TIN = vtkDelaunay2D()
interp_TIN.SetInputData(polydata)
interp_TIN.Update()

# update TIN with true elevations
display_TIN = vtkWarpScalar()
display_TIN.SetInputConnection(interp_TIN.GetOutputPort())
display_TIN.Update()

```

While I am able to get the triangulated terrain displayed, I am unable to get it oriented correctly with Y values representing elevation and Z values representing depth. I understand that this is because of how I generated the triangulation BUT I have not been able to find another way to do this so that Y axis corresponds to elevations and Z to depth.

Can anyone tell me how I could accomplish this?

---

<div class="post-metadata">

### Author: ![Paulo\_Carvalho](https://discourse.vtk.org/user_avatar/discourse.vtk.org/paulo_carvalho/32/370_2.png) [@Paulo\_Carvalho](https://discourse.vtk.org/u/Paulo_Carvalho)
#### Post date: [October 20, 2022, 2:32pm UTC](https://discourse.vtk.org/t/how-to-generate-a-triangulation-with-the-correct-orientation/9599/2 "2022-10-20T14:32:20Z")

</div>

Hello,

In my understanding, elevation and depth are the same thing: the Z coordinate (the former has positive values and the latter, negative values), right? So, I think you need to illustrate what you’re getting and what you expect.

take care,

Paulo
