Hello,

I did not work with ESRI or ERDAS grids yet, but the following code segments 
should work for ASCII and GeoTiff (using GT2.2.0):

Importing ASCII-Grids
===============
import java.io.InputStream;
import java.io.InputStreamReader;
import java.awt.geom.Rectangle2D;
import java.awt.image.WritableRaster;
import org.geotools.gce.arcgrid.ArcGridRaster;
import org.geotools.geometry.Envelope2D;
import org.geotools.coverage.grid.GridCoverage2D;
import org.geotools.coverage.grid.GridCoverageFactory;
...
InputStream input = ...;
ArcGridRaster reader = new ArcGridRaster(
                           new InputStreamReader(input) );
WritableRaster raster = reader.readRaster();
float x = (float)reader.getXlCorner(); // South West
float y = (float)reader.getYlCorner(); // South West
float w = (float)(reader.getNCols() * reader.getCellSize());
float h = (float)(reader.getNRows() * reader.getCellSize());
Envelope2D envelope = new Envelope2D(null,
                          new Rectangle2D.Float(x,y,w,h));
GridCoverage2D grid = new GridCoverageFactory().create(
                          "My Grid", raster, envelope);


Importing GeoTiff-Grids
================
import java.io.File;
import org.geotools.gce.geotiff.GeoTiffFormat;
import org.geotools.coverage.grid.GridCoverage2D;
...
File input = ...;
GeoTiffFormat format = new GeoTiffFormat();
GridCoverage2D grid = 
  (GridCoverage2D)format.getReader(input).read(null);


With kind regards...

Martin Schmitz


> -----Ursprüngliche Nachricht-----
> Von: "Hari S. Khalsa" <[EMAIL PROTECTED]>
> Gesendet: 17.11.06 15:33:33
> An: [email protected]
> Betreff: [Geotools-gt2-users] working with rasters


> Hi All,
> 
> This is my first post to these forums.  I'm currently having an issue 
> relating to working with rasters in Geotools.  However, before I describe 
> it, I was wondering if anyone here could give me some general help.  I've 
> been working with Geotools for a couple of months now but I've just used it 
> for it's shapefile reading/writing ability and the JTS geometry 
> functionality.  All this time, I've been somewhat confused by the 
> organization of the web site and all Geotools resources in general.  I even 
> find this user forum hard to read as it seems that the spacings and 
> carriage returns get messed up in replies to people's questions.  Where is 
> the best place to find help using Geotools?  Is it this forum?  Is there a 
> Developer's Guide somewhere because the link on the website to a developers 
> guide brings up a 404 error (http://geotools.codehaus.org/display/GEOT/Home)?
> 
> Currently I'm trying to read in an ERDAS imagine file.  I don't think there 
> is any support for this in Geotools, but I haven't been able to make a 
> definitive determination on this.  I converted the ERDAS file into the ESRI 
> raster format and then into ASCII text hoping to follow the example given 
> on the following webpage 
> http://geotools.codehaus.org/Using+Grid+Coverage+Exchange
> 
> Unfortunately this example does not work.  Can anyone provide me with a 
> method for reading in a raster in any of the three aforementioned formats 
> (ESRI, ERDAS, or ASCII)?  I don't even have a GUI on my code, my ultimate 
> goal is to simply determine the underlying raster values below a vector 
> polygon.  I'm sure I'll have issues with projections later, but for now I 
> just want to be able to read in the raster data.
> 
> Thanks,
> Hari
> 
> 
> -------------------------------------------------------------------------
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to share your
> opinions on IT & business topics through brief surveys - and earn cash
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
> _______________________________________________
> Geotools-gt2-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

_____________________________________________________________________
Der WEB.DE SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen!
http://smartsurfer.web.de/?mc=100071&distributionid=000000000066


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to