Hello to everyone,
i start to work with GT2 because i need to handle some Geotiff files for my
job's projects.
I have two different kind of problems:
1->
I need to request a Geotiff to a Geoserver, and i use this simple request to
get the data:
URL geoturl = new URL("
http://localhost:8080/geoserver/wcs?service=WCS&request=GetCoverage&coverage=geodata_mpba:Tgrd_20080501_AVG&version=1.0.0&format=geotiff&CRS=EPSG:32632&BBOX=612267.0,5059445.0,728667.0,5157245.0&width=800&height=630&srs=EPSG:32632
");
I read it with:
GeoTiffReader primageo = new GeoTiffReader(geoturl);
And the problem start when i do this:
GridCoverage2D gc = primageo.read(null);
I cannot read the InputStream from the Geoserver, it would be great to know
how to interface a Geoserver's URL-request. Do i have to use other classes?
Do i have to do some kind of type cast?
2-> I need to set the NoDataValue in a GridCoverage. My code is this:
File aFile;
GeoTiffReader aTiff;
WritableRaster amap;
WritableRaster temp = null;
Envelope2D envelope = null;
ColorModel colormodel = null;
GridCoverageFactory fact =
FactoryFinder.getGridCoverageFactory(null);
aFile = new File("/home/calogero/Tgrd_2008.tif");
aTiff = new GeoTiffReader(aFile);
amap = ((GridCoverage2D)
aTiff.read(null)).getRenderedImage().copyData(null);
temp = amap.createCompatibleWritableRaster();
envelope = ((GridCoverage2D) aTiff.read(null)).getEnvelope2D();
colormodel = ((GridCoverage2D)
aTiff.read(null)).getRenderedImage().getColorModel();
temp = this.AddConstant(amap, -20.0);
BufferedImage img = new BufferedImage(colormodel,temp,false,null);
GridCoverage2D ih2008 = fact.create("Out", img, envelope);
File file_ih2008 = new File("/home/calogero/out2008.tif");
GeoTiffFormat format = new GeoTiffFormat();
GeoTiffWriter writer = (GeoTiffWriter)format.getWriter(file_ih2008
);
writer.write(ih2008, null);
In this example i read a GeoTiff from my local HardDisk, i add -20 to each
sample value except the ones that show -9999 as value, and i try to store
the result back to my HardDrive.
Everything work fine and i can open this file with QuantumGis.
My problem is that i need to set from code the NoDataValue, and i don't know
where to find something like setNoDataValue(double val), or another method
like that.
------------------------------------------------------------------------------
SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
http://p.sf.net/sfu/solaris-dev2dev
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users