vtkGeoGraticle generates polydata to illustrate the distortions introduced by a map projection. The level parameter specifies the number of lines to be drawn. Poles are treated differently than other regions; hence the use of a Level parameter instead of a NumberOfLines parameter. The latitude and longitude are specified as half-open intervals with units of degrees. By default the latitude bounds are (-90,90) and the longitude bounds are (0,180).

Other Languages

See (Cxx)


If you have a simple question about this example contact us at VTKExamplesProject If your question is more complex and may require extended discussion, please use the VTK Discourse Forum


#!/usr/bin/env python
import vtk
def main():
    colors = vtk.vtkNamedColors()
    geoGraticle = vtk.vtkGeoGraticule()
    transformProjection = vtk.vtkGeoTransform()
    destinationProjection = vtk.vtkGeoProjection()
    sourceProjection = vtk.vtkGeoProjection()
    transformGraticle = vtk.vtkTransformFilter()

    reader = vtk.vtkXMLPolyDataReader()
    transformReader = vtk.vtkTransformFilter()
    graticleMapper = vtk.vtkPolyDataMapper()
    readerMapper = vtk.vtkPolyDataMapper()
    graticleActor = vtk.vtkActor()
    readerActor = vtk.vtkActor()

    geoGraticle.SetGeometryType( geoGraticle.POLYLINES )
    geoGraticle.SetLatitudeLevel( 2 )
    geoGraticle.SetLongitudeLevel( 2 )
    geoGraticle.SetLongitudeBounds( -180, 180 )
    geoGraticle.SetLatitudeBounds( -90, 90 )

    # destinationProjection defaults to latlong.
    destinationProjection.SetName( "rouss" )
    destinationProjection.SetCentralMeridian( 0. )
    transformProjection.SetSourceProjection( sourceProjection )
    transformProjection.SetDestinationProjection( destinationProjection )
    transformGraticle.SetInputConnection( geoGraticle.GetOutputPort() )
    transformGraticle.SetTransform( transformProjection )
    graticleMapper.SetInputConnection( transformGraticle.GetOutputPort() )
    graticleActor.SetMapper( graticleMapper )

    renderWindow = vtk.vtkRenderWindow()
    renderer = vtk.vtkRenderer()
    interactor = vtk.vtkRenderWindowInteractor()
    renderWindow.SetInteractor( interactor )
    renderWindow.AddRenderer( renderer )
    renderWindow.SetSize(640, 480)

    renderer.AddActor( readerActor )
    renderer.AddActor( graticleActor )


if __name__ == '__main__':