VTK/Examples/Python/Geovis/GeoAssignCoordinates

From KitwarePublic
< VTK‎ | Examples‎ | Python
Revision as of 06:30, 21 September 2010 by Daviddoria (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

GeoAssignCoordinates.py

#!/usr/bin/python
 
import vtk
 
g = vtk.vtkMutableDirectedGraph()
latitude = vtk.vtkDoubleArray()
latitude.SetName("latitude")
longitude = vtk.vtkDoubleArray()
longitude.SetName("longitude")
for i in range(-90, 90, 10):
    for j in range(-180, 180, 20):
        g.AddVertex()
        latitude.InsertNextValue(i)
        longitude.InsertNextValue(j)
g.GetVertexData().AddArray(latitude)
g.GetVertexData().AddArray(longitude)
 
assign = vtk.vtkGeoAssignCoordinates()
assign.SetInput(g)
assign.SetLatitudeArrayName("latitude")
assign.SetLongitudeArrayName("longitude")
assign.SetGlobeRadius(1.0)
assign.Update()
 
mapper = vtk.vtkGraphMapper()
mapper.SetInputConnection(assign.GetOutputPort())
actor = vtk.vtkActor()
actor.SetMapper(mapper)
ren = vtk.vtkRenderer()
ren.AddActor(actor)
iren = vtk.vtkRenderWindowInteractor()
win = vtk.vtkRenderWindow()
win.AddRenderer(ren)
win.SetInteractor(iren)
ren.ResetCamera()
 
iren.Initialize()
iren.Start()