# GeoAssignCoordinates

Repository source: GeoAssignCoordinates

### Description¶

Given latitude and longitude arrays, take the values in those arrays and convert them to x,y,z world coordinates.

Uses a spherical model of the earth to do the conversion. The position is in meters relative to the center of the earth.

If a transform is given, use the transform to convert latitude and longitude to the world coordinate.

Note

The vtkGeovisCore classes as well as the module vtkViewsGeovis have been deprecated for VTK 8.2 and will be removed in a future version. See VTK Merge Request 4395

Question

### Code¶

GeoAssignCoordinates.java

import vtk.vtkNativeLibrary;
import vtk.vtkRenderWindow;
import vtk.vtkRenderWindowInteractor;
import vtk.vtkRenderer;
import vtk.vtkActor;
import vtk.vtkMutableDirectedGraph;
import vtk.vtkDoubleArray;
import vtk.vtkGeoAssignCoordinates;
import vtk.vtkGraphMapper;

public class GeoAssignCoordinates
{
// -----------------------------------------------------------------
// Load VTK library and print which library was not properly loaded
static
{
{
for (vtkNativeLibrary lib : vtkNativeLibrary.values())
{
{
}
}
}
vtkNativeLibrary.DisableOutputWindow(null);
}
// -----------------------------------------------------------------

public static void main(String args[])
{
vtkMutableDirectedGraph g = new vtkMutableDirectedGraph();
vtkDoubleArray latitude = new vtkDoubleArray();
latitude.SetName("latitude");

vtkDoubleArray longitude = new vtkDoubleArray();
longitude.SetName("longitude");

for(int lat = -90; lat <= 90; lat += 10)
{
for(int lon = -180; lon <= 180; lon += 20)
{
latitude.InsertNextValue(lat);
longitude.InsertNextValue(lon);
}
}

vtkGeoAssignCoordinates assign = new vtkGeoAssignCoordinates();
assign.SetInputData(g);
assign.SetLatitudeArrayName("latitude");
assign.SetLongitudeArrayName("longitude");
assign.Update();

vtkGraphMapper mapper = new vtkGraphMapper();
mapper.SetInputConnection(assign.GetOutputPort());

vtkActor actor = new vtkActor();
actor.SetMapper(mapper);

// Create the renderer, render window and interactor.
vtkRenderer ren = new vtkRenderer();
vtkRenderWindow renWin = new vtkRenderWindow();
vtkRenderWindowInteractor iren = new vtkRenderWindowInteractor();
iren.SetRenderWindow(renWin);