Visualization for GeoScience

Shared by: HC120911025717
Categories
Tags
-
Stats
views:
6
posted:
9/10/2012
language:
English
pages:
41
Document Sample
scope of work template
							      Toolkits for
GeoScience Visualization
  Dave Nadeau, John Moreland
           SDSC
Tools 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

• Let’s look at some toolkits for building tools


        Cyberinfrastructure Summer Institute for Geoscientists
Tools for custom visualization
• Java Image I/O
• GeoTIFF
• Java OpenGL
• GeoTools
• WorldWind
• NetCDF


       Cyberinfrastructure Summer Institute for Geoscientists
                Java 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/



         Cyberinfrastructure Summer Institute for Geoscientists
        Java Image I/O example
1. Get an image reader:
ImageInputStream stream =
  ImageIO.createImageInputStream(file);

Iterator<ImageReader> it =
   ImageIO.getImageReaders(stream);
ImageReader reader = it.next();

reader.setInput(stream);



           Cyberinfrastructure Summer Institute for Geoscientists
       Java Image I/O example
2. Read the image:
BufferedImage image = reader.read(0);


3. Display the image:
ImageIcon icon = new ImageIcon(image);
Jlabel label = new Jlabel(icon);
frame.add(label,BorderLayout.CENTER);




          Cyberinfrastructure Summer Institute for Geoscientists
Java Image I/O example




 Cyberinfrastructure Summer Institute for Geoscientists
                        GeoTIFF
• 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/


         Cyberinfrastructure Summer Institute for Geoscientists
              GeoTIFF example
1. Get a TIFF image reader (same!):
ImageInputStream stream =
  ImageIO.createImageInputStream(file);

Iterator<ImageReader> it =
   ImageIO.getImageReaders(stream);
ImageReader reader = it.next();

reader.setInput(stream);



           Cyberinfrastructure Summer Institute for Geoscientists
             GeoTIFF example
2. Read the image (same!): :
BufferedImage image = reader.read(0);


3. Display the image (same!): :
ImageIcon icon = new ImageIcon(image);
Jlabel label = new Jlabel(icon);
frame.add(label,BorderLayout.CENTER);




          Cyberinfrastructure Summer Institute for Geoscientists
             GeoTIFF example
4. Get the GeoTIFF metadata:
IIOMetadata meta = reader.getImageMetadata(0);
GeoTiffIIOMetadataAdapter ameta =
   new GeoTiffIIOMetadataAdapter(meta);

String value = ameta.getGeoKey(key);




          Cyberinfrastructure Summer Institute for Geoscientists
                         GeoTIFF example
• Available keys:
  –   GTModelTypeGeoKey             –   ProjectedCSTypeGeoKey           –   ProjCenterLongGeoKey

  –   GTRasterTypeGeoKey            –   PCSCitationGeoKey               –   ProjCenterLatGeoKey

  –   GTCitationGeoKey              –   ProjectionGeoKey                –   ProjCenterEastingGeoKey

  –   GeographicTypeGeoKey          –   ProjCoordTransGeoKey            –   ProjCenterNorthingGeoKey

  –   GeogCitationGeoKey            –   ProjLinearUnitsGeoKey           –   ProjScaleAtNatOriginGeoKey

  –   GeogGeodeticDatumGeoKey       –   ProjLinearUnitSizeGeoKey        –   ProjScaleAtCenterGeoKey

  –   GeogPrimeMeridianGeoKey       –   ProjStdParallel1GeoKey          –   ProjAzimuthAngleGeoKey

  –   GeogPrimeMeridianLongGeoKey   –   ProjStdParallel2GeoKey          –   ProjStraightVertPoleLongGeoKey

  –   GeogLinearUnitsGeoKey         –   ProjNatOriginLongGeoKey         –   VerticalCSTypeGeoKey

  –   GeogLinearUnitSizeGeoKey      –   ProjNatOriginLatGeoKey          –   VerticalCitationGeoKey

  –   GeogAngularUnitsGeoKey        –   ProjFalseEastingGeoKey          –   VerticalDatumGeoKey

  –   GeogAngularUnitsSizeGeoKey    –   ProjFalseNorthingGeoKey         –   VerticalUnitsGeoKey

  –   GeogEllipsoidGeoKey           –   ProjFalseOriginLongGeoKey

  –   GeogSemiMajorAxisGeoKey       –   ProjFalseOriginLatGeoKey

  –   GeogSemiMinorAxisGeoKey       –   ProjFalseOriginEastingGeoKey

  –   GeogInvFlatteningGeoKey       –   ProjFalseOriginNorthingGeoKey

  –   GeogAzimuthUnitsGeoKey




                 Cyberinfrastructure Summer Institute for Geoscientists
   GeoTIFF example




Cyberinfrastructure Summer Institute for Geoscientists
         Java 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/



          Cyberinfrastructure Summer Institute for Geoscientists
        Java OpenGL (JOGL)
• Draw points, lines, polygons
• Control point & line size, line patterns,
  polygon fill, color, texture
• Control 3D lighting
• All done at hardware speeds




         Cyberinfrastructure Summer Institute for Geoscientists
       JOGL example: polygons
1. Set a drawing color:
gl.glColor3f(r,g,b);


2. Draw a polygon:
gl.glBegin(GL.GL_POLYGON);
   gl.glVertex3f(x,y,z);
   ...
gl.glEnd();




            Cyberinfrastructure Summer Institute for Geoscientists
JOGL example: polygons




  Cyberinfrastructure Summer Institute for Geoscientists
        JOGL example: images
1. Create texture from graphics context:
Texture tex= TextureIO.newTexture(file,false);
gl.glEnable(GL.GL_TEXTURE_2D);
tex.bind();
tex.enable();

2. Draw shape using texture:
gl.glTexCoord2f(s,t);
gl.glVertex3f(x,y,z);



           Cyberinfrastructure Summer Institute for Geoscientists
JOGL example: images




 Cyberinfrastructure Summer Institute for Geoscientists
                       GeoTools
• Toolkit implementing OGC GeoAPI
  – Read/write many file formats
  – Features, images, geometry, coord spaces
  – WMS, WFS
  – Open source

http://geotools.codehaus.org/



         Cyberinfrastructure Summer Institute for Geoscientists
  GeoTools example: Shapefile
1. Create a data store to read a file:
DataStore dataStore =
  FileDataStoreFinder.getDataStore(url);



2. Get the first feature source:
String[] names = dataStore.getTypeNames();
FeatureSource source =
  dataStore.getFeatureSource(names[0]);



           Cyberinfrastructure Summer Institute for Geoscientists
  GeoTools example: Shapefile
3. Create a map context:
CoordinateReferenceSystem crs =
  CRS.decode(“EPSG:4326”);
DefaultMapContext context =
  new DefaultMapContext(crs);



4. Add feature source to context:
context.addLayer(source,new BasicLineStyle());



           Cyberinfrastructure Summer Institute for Geoscientists
  GeoTools example: Shapefile
5. Draw the map context:
MapContextPanel panel = new MapContextPanel();
panel.setContext(context);
frame.add(panel,BorderLayout.CENTER);




          Cyberinfrastructure Summer Institute for Geoscientists
GeoTools example: Shapefile




    Cyberinfrastructure Summer Institute for Geoscientists
                             NetCDF
• 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/




            Cyberinfrastructure Summer Institute for Geoscientists
                          NetCDF
• 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

         Cyberinfrastructure Summer Institute for Geoscientists
                NetCDF example
1. Open a NetCDF file:
NetcdfFile ncfile = NetcdfFile.open(file);


2. Get data variables:
List variables = ncfile.getVariables();
Variable var = (Variable)variables.get(i);
Array array = var.read();




            Cyberinfrastructure Summer Institute for Geoscientists
                NetCDF example
 3. Get variable dimensions:
int rank = var.getRank();
int[] shape = array.getShape();



 4. Get voxels:
double voxel =
  ((ArrayDouble.D3)array).get(i,j,k);




            Cyberinfrastructure Summer Institute for Geoscientists
                 NetCDF example
 5. Get global or variable attributes:
List glist = ncfile.getGlobalAttributes();
List vlist = var.getAttributes();
Attribute attrib = vlist.get(i);

 6. Get attribute type and value:
DataType type = attrib.getDataType();
Number num = attrib.getNumericValue(i);
String str = attrib.getStringValue(i);



             Cyberinfrastructure Summer Institute for Geoscientists
                NetCDF example
 7. Build an image:
BufferedImage image = new BufferedImage(w,h);

int gray = (int)(voxel * 255);
int rgba = (gray<<24) | (gray<<16) ...;
image.setRGB(row,col,rgba);




            Cyberinfrastructure Summer Institute for Geoscientists
    NetCDF example




Cyberinfrastructure Summer Institute for Geoscientists
      NASA 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/




            Cyberinfrastructure Summer Institute for Geoscientists
NWW HelloWorldWind example
1. Create a canvas:
WorldWindGLCanvas c = new WorldWindGLCanvas();

2. Set a data model:
c.setModel( new BasicModel() );

3. Add canvas to your application interface:
frame.add( c );




           Cyberinfrastructure Summer Institute for Geoscientists
NWW HelloWorldWind output




   Cyberinfrastructure Summer Institute for Geoscientists
     NWW LayerDemo example
1. Create a surface image:
SurfaceImage si = new SurfaceImage( “Map.png”,
Sector.fromDegrees(35, 45, -115, -95) );

2. Make it semi-transparent:
si.setOpacity( 0.7 );

3. Add the image to a renderable layer:
RenderableLayer rl = new RenderableLayer();
rl.addRenderable( si );


            Cyberinfrastructure Summer Institute for Geoscientists
      NWW LayerDemo example
4. Get the LayerList from the model:
LayerList layers = model.getLayers( );

5. Add our image layer:
layers.add( layers.size(), rl );




            Cyberinfrastructure Summer Institute for Geoscientists
NWW LayerDemo output




 Cyberinfrastructure Summer Institute for Geoscientists
      NWW WmsDemo example
1. Create a WMS Layer:
OpenStreetMapLayer os=newOpenStreetMapLayer();

2. Get the LayerList from the model:
LayerList layers = model.getLayers( );

3. Add the WMS layer:
layers.add( layers.size(), os );




            Cyberinfrastructure Summer Institute for Geoscientists
NWW WmsDemo output




 Cyberinfrastructure Summer Institute for Geoscientists
                          Conclusions
• Lot’s 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 …




                Cyberinfrastructure Summer Institute for Geoscientists
      Open 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…




          Cyberinfrastructure Summer Institute for Geoscientists

						
Related docs
Other docs by HC120911025717
Please distribute Widely
Views: 0  |  Downloads: 0
Envirobond F200
Views: 6  |  Downloads: 0
Friday Week 1
Views: 0  |  Downloads: 0
Microsoft SQL Server - Audit Checklist
Views: 48  |  Downloads: 1
Pemrograman Web
Views: 19  |  Downloads: 0
Project Summary
Views: 0  |  Downloads: 0
PowerPoint Presentation
Views: 4  |  Downloads: 0
Data Warehousing - 3
Views: 2  |  Downloads: 0