[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
| Re: [udig-devel] raster's data recovery | 
ragga doll wrote:
Hi,
I have experienced some problem with raster’s data recovery. I have 
imported cloud.jpg from udig’s data sample (data-v1_1). And with this 
code, I always get one value (not three for each R G B) and this value 
is always 0.
I am trying to understand what is going on; so you imported this 
cloud.jpg as a GridCoverage?
An other problem : I can’t import a geotiff raster with raster’ pixel 
value more than 255 (I am not sure of that). Can uDig import raster 
geotiff or can uDig import simple picture only ?
For any serious raster work I recommend working on uDig trunk; the 
raster support has been rewritten from the ground up and is much better. 
uDig can work with a GeoTiff (and also with a Tiff+world file). For a 
GeoTiff the only magic is in extracting the bounds and crs out of the 
Tiff header.
Please some one can told me what’s wrong ? Is there a kind of  
tutorial or code snippet on this subject ?
For working on rasters the GeoTools user guide will have a really small 
amount of information. The GeoTools test cases and user email list are 
the best source of information.
GridCoverageFactory fact = new GridCoverageFactory();       
Map map = (Map) ApplicationGIS.getActiveMap() ;       
Layer l = (Layer) map.getMapLayers().get(0) ; //my picture
       
int tabValue[] = null ; //sure values are integer one
    
RenderedImage image = 
map.getRenderManagerInternal().getRendererCreator().getRenderContext(l).getImage() 
;
       
Envelope envelope = l.getBounds(null, l.getCRS()) ;       
GridCoverage2D grid = fact.create("name", image, envelope) ;
       
Point2D.Double pixel = new Point2D.Double(-65.157, -7.736) ; //I am 
sure there is no cloud there ;)
       
tabValue = grid.evaluate(pixel, tabValue) ;
               
for(int i = 0 ; i < tabValue.length ; i++)
    msg = "\n*" + tabValue[i] ;
       
System.out.println(msg);       
For this example it looks like you are trying to look at the image dran 
on screen by the rendering system. You don't need to do this; you should 
be accessing the data directly. By the time something shows up on screen 
it will be processed by RasterSymbolizers and scaled and colored, and 
generally no longer a GeoTiff.
So I think what you want is to create an IOp asking for a 
GridCoverage... the uDig framework will sort out the rest. You can right 
click on your layer or catalog entry and start hacking on the 
GridCoverage. For a low level take on how to do this by hand using 
GeoTools review this page:
- http://docs.codehaus.org/display/GEOTDOC/02+GridCoverageReader
Jody