Title: Toolkits for GeoScience Visualization
1Toolkits forGeoScience Visualization
- Dave Nadeau, John Moreland
- SDSC
2Tools for custom visualization
- Lots of great GeoVis tools out there
- What if you need something custom?
- Convert to/from a custom file format
- Analyze and filter data
- Custom visualization and interaction
- Lets look at some toolkits for building tools
3Tools for custom visualization
- Java Image I/O
- GeoTIFF
- Java OpenGL
- GeoTools
- WorldWind
- NetCDF
4Java Image I/O
- Sun Java toolkit for image file read/write
- Many formats
- BMP, GIF, PNG, JPEG, JPEG2000, TIFF
- Also use advanced imaging toolkit for filtering
- Standard part of Java
- http//java.sun.com/
5Java Image I/O example
ImageInputStream stream ImageIO.createImageI
nputStream(file) IteratorltImageReadergt it
ImageIO.getImageReaders(stream) ImageReader
reader it.next() reader.setInput(stream)
6Java Image I/O example
- Read the image
- Display the image
BufferedImage image reader.read(0)
ImageIcon icon new ImageIcon(image) Jlabel
label new Jlabel(icon) frame.add(label,Border
Layout.CENTER)
7Java Image I/O example
8GeoTIFF
- TIFF image format with Geo tags
- Coordinate space, position, extent
- Readable by TIFF tools (Java Image I/O)
- GeoTIFF metadata adapter understands tags
- Open Source
- http//remotesensing.org/geotiff/
- http//gelbin.org/code/
9GeoTIFF example
- Get a TIFF image reader (same!)
ImageInputStream stream ImageIO.createImageI
nputStream(file) IteratorltImageReadergt it
ImageIO.getImageReaders(stream) ImageReader
reader it.next() reader.setInput(stream)
10GeoTIFF example
- Read the image (same!)
- Display the image (same!)
BufferedImage image reader.read(0)
ImageIcon icon new ImageIcon(image) Jlabel
label new Jlabel(icon) frame.add(label,Border
Layout.CENTER)
11GeoTIFF example
IIOMetadata meta reader.getImageMetadata(0) Geo
TiffIIOMetadataAdapter ameta new
GeoTiffIIOMetadataAdapter(meta) String value
ameta.getGeoKey(key)
12GeoTIFF example
- Available keys
- GTModelTypeGeoKey
- GTRasterTypeGeoKey
- GTCitationGeoKey
- GeographicTypeGeoKey
- GeogCitationGeoKey
- GeogGeodeticDatumGeoKey
- GeogPrimeMeridianGeoKey
- GeogPrimeMeridianLongGeoKey
- GeogLinearUnitsGeoKey
- GeogLinearUnitSizeGeoKey
- GeogAngularUnitsGeoKey
- GeogAngularUnitsSizeGeoKey
- GeogEllipsoidGeoKey
- GeogSemiMajorAxisGeoKey
- GeogSemiMinorAxisGeoKey
- GeogInvFlatteningGeoKey
- GeogAzimuthUnitsGeoKey
- ProjCenterLongGeoKey
- ProjCenterLatGeoKey
- ProjCenterEastingGeoKey
- ProjCenterNorthingGeoKey
- ProjScaleAtNatOriginGeoKey
- ProjScaleAtCenterGeoKey
- ProjAzimuthAngleGeoKey
- ProjStraightVertPoleLongGeoKey
- VerticalCSTypeGeoKey
- VerticalCitationGeoKey
- VerticalDatumGeoKey
- VerticalUnitsGeoKey
- ProjectedCSTypeGeoKey
- PCSCitationGeoKey
- ProjectionGeoKey
- ProjCoordTransGeoKey
- ProjLinearUnitsGeoKey
- ProjLinearUnitSizeGeoKey
- ProjStdParallel1GeoKey
- ProjStdParallel2GeoKey
- ProjNatOriginLongGeoKey
- ProjNatOriginLatGeoKey
- ProjFalseEastingGeoKey
- ProjFalseNorthingGeoKey
- ProjFalseOriginLongGeoKey
- ProjFalseOriginLatGeoKey
- ProjFalseOriginEastingGeoKey
- ProjFalseOriginNorthingGeoKey
13GeoTIFF example
14Java OpenGL (JOGL)
- Sun Java toolkit for OpenGL 3D drawing
- Uses native OpenGL to 3D graphics hardware
- Integrates with rest of Java toolkit
- Not part of Java distribution, but easily added
- https//jogl.dev.java.net/
15Java OpenGL (JOGL)
- Draw points, lines, polygons
- Control point line size, line patterns, polygon
fill, color, texture - Control 3D lighting
- All done at hardware speeds
16JOGL example polygons
- Set a drawing color
- Draw a polygon
gl.glColor3f(r,g,b)
gl.glBegin(GL.GL_POLYGON) gl.glVertex3f(x,y,z
) ... gl.glEnd()
17JOGL example polygons
18JOGL example images
- Create texture from graphics context
- Draw shape using texture
Texture tex TextureIO.newTexture(file,false) gl.
glEnable(GL.GL_TEXTURE_2D) tex.bind() tex.enable
()
gl.glTexCoord2f(s,t) gl.glVertex3f(x,y,z)
19JOGL example images
20GeoTools
- Toolkit implementing OGC GeoAPI
- Read/write many file formats
- Features, images, geometry, coord spaces
- WMS, WFS
- Open source
- http//geotools.codehaus.org/
21GeoTools example Shapefile
- Create a data store to read a file
- Get the first feature source
DataStore dataStore FileDataStoreFinder.getD
ataStore(url)
String names dataStore.getTypeNames() Feature
Source source dataStore.getFeatureSource(nam
es0)
22GeoTools example Shapefile
- Create a map context
- Add feature source to context
CoordinateReferenceSystem crs
CRS.decode(EPSG4326) DefaultMapContext
context new DefaultMapContext(crs)
context.addLayer(source,new BasicLineStyle())
23GeoTools example Shapefile
MapContextPanel panel new MapContextPanel() pan
el.setContext(context) frame.add(panel,BorderLayo
ut.CENTER)
24GeoTools example Shapefile
25NetCDF
- Network Common Data Form
- File format toolkit to read/write
multidimensional data (eg Volumes) - Support for many programming languages (such as
Java) - University Corporation for Atmospheric Research
(UCAR) / UNAVCO - http//www.unidata.ucar.edu/software/netcdf/
26NetCDF
- Variables hold multidimensional data values
- char, byte, short, int, float, double
- Attributes hold meta-data
- Units, names, scale factors, etc.
- Attributes can be global or associated with each
variable
27NetCDF example
- Open a NetCDF file
- Get data variables
NetcdfFile ncfile NetcdfFile.open(file)
List variables ncfile.getVariables() Variable
var (Variable)variables.get(i) Array array
var.read()
28NetCDF example
- Get variable dimensions
- Get voxels
int rank var.getRank() int shape
array.getShape()
double voxel ((ArrayDouble.D3)array).get(i,j
,k)
29NetCDF example
- Get global or variable attributes
- Get attribute type and value
List glist ncfile.getGlobalAttributes() List
vlist var.getAttributes() Attribute attrib
vlist.get(i)
DataType type attrib.getDataType() Number num
attrib.getNumericValue(i) String str
attrib.getStringValue(i)
30NetCDF example
BufferedImage image new BufferedImage(w,h) int
gray (int)(voxel 255) int rgba (grayltlt24)
(grayltlt16) ... image.setRGB(row,col,rgba)
31NetCDF example
32NASA World Wind (NWW)
- Open-Source Google Earth
- Toolkit (modular library for building
applications) - Versions for .NET (Windows) and Java (Mac,
Windows, UNIX) - Tiled Terrain and Images, WMS, Plug-in Layers, 3D
Rendering (JOGL) - NASA / ARC (Ames Research Center)
- http//worldwind.arc.nasa.gov/
33NWW HelloWorldWind example
- Create a canvas
- Set a data model
- Add canvas to your application interface
WorldWindGLCanvas c new WorldWindGLCanvas()
c.setModel( new BasicModel() )
frame.add( c )
34NWW HelloWorldWind output
35NWW LayerDemo example
- Create a surface image
- Make it semi-transparent
- Add the image to a renderable layer
SurfaceImage si new SurfaceImage( Map.png,
Sector.fromDegrees(35, 45, -115, -95) )
si.setOpacity( 0.7 )
RenderableLayer rl new RenderableLayer() rl.add
Renderable( si )
36NWW LayerDemo example
- Get the LayerList from the model
- Add our image layer
LayerList layers model.getLayers( )
layers.add( layers.size(), rl )
37NWW LayerDemo output
38NWW WmsDemo example
- Create a WMS Layer
- Get the LayerList from the model
- Add the WMS layer
OpenStreetMapLayer osnewOpenStreetMapLayer()
LayerList layers model.getLayers( )
layers.add( layers.size(), os )
39NWW WmsDemo output
40Conclusions
- Lots of good Java toolkits available
- Image I/O Sun Java Image I/O
- Image filtering Sun Java Advanced Imaging
- GeoTIFF GeoTools, WorldWind, GeoTIFF adapter
- Movie I/O Sun Java Media Framework
- Shapefile I/O GeoTools
- Volume I/O NetCDF, HDF
- Metadata Sun Java Metadata Interface
- GUIs Sun JDK, SwingX
- 3D Sun JOGL, Sun Java3D
- Projections GeoTools, SRI GeoTransform
- GML, WFS GeoTools
- WMS GeoTools, WorldWind
- Net protocols Sun JDK, Apache Commons net, Apache
HTTP components - Web protocols Sun Metro, Apache Web Services
- lots more
41Open Earth Framework
- Services architecture
- Server-side data management, filtering,
pre-processing - Client-side presentation, interaction
- Java toolkit
- Integrates other toolkits
- Adds missing GeoVis functionality
- In development