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
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?