[vtkusers] How to apply color map for each horizontal slice of a rectilinear grid

Manjunath K E ke.manjunath at gmail.com
Wed Jul 29 05:29:31 EDT 2015


Hi All

I have rectilinear grid read from a netcdf ocean data file with X, Y, Z
axes.

Currently I have applied a color map for entire rectilinear grid by finding
out its min and max values.

currently my code looks like this.
=============================================
#Read file in the NetCDF foramat
netCdfReader = vtkNetCDFCFReader()
netCdfReader.SetFileName("netCdfFilename.nc")
netCdfReader.SphericalCoordinatesOff()
netCdfReader.SetReplaceFillValueWithNan(1)
netCdfReader.Update()

#Find the min max range of values
a, b= netCdfReader.GetOutput().GetPointData().GetScalars().GetRange()
#create a look up table for color mapping
lut = vtk.vtkColorTransferFunction()
lut.AddRGBPoint(a,         0.0, 0.0, 1.0)
lut.AddRGBPoint(a+(b-a)/4, 0.0, 0.5, 0.5)
lut.AddRGBPoint(a+(b-a)/2, 0.0, 1.0, 0.0)
lut.AddRGBPoint(b-(b-a)/4, 0.5, 0.5, 0.0)
lut.AddRGBPoint(b,         1.0, 0.0, 0.0)
lut.SetNanColor(0.7,0.7,0.7)#gray color

gridMapper = vtkDataSetMapper()
gridMapper.SetInputData( netCdfReader.GetOutput() )
gridMapper.SetScalarModeToUsePointData()
gridMapper.SetLookupTable(lut)
============================================

Now I would like to find (min, max) values of each horizontal slice (for
each value of Z).

I want get (min, max) values for each value of Z axes and apply the color
map that particular slice, according the obtained (min, max) range.
Could anyone help me on this.
 Thanks and Regards,

 Manjunath K E
 Help Ever Hurt Never
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20150729/04de25da/attachment.html>


More information about the vtkusers mailing list