I am currently trying to :
- get many geotiffs files,
- crop them to get only the area i need,
- write the new geotiffs,
- delete the old geotiffs from my directory.
My problem is the next one :
When I try to remove the old tiff files, It is impossible...
This is my code :
for(int i = 0; i < files.length; i++){
try{
/* We read the coverage and crop it. */
reader = new GeoTiffReader(files[i], hints);
GridCoverage2D temp = (GridCoverage2D)reader.read(null);
/* We crop this coverage and put it into a second coverage. */
paramCrop.parameter("Source").setValue(temp);
paramCrop.parameter("Envelope").setValue(crop);
GridCoverage2D temp2 =
(GridCoverage2D)processor.doOperation(paramCrop);
/* We write out the new coverage into geotiff file. */
File outFile = new
File(MSS_ControlProject.getRastersPath()+File.separator+i+".TIF");
GeoTiffWriter gtw = (GeoTiffWriter)format.getWriter(outFile);
gtw.write(temp2,(GeneralParameterValue[])paramWrite.values().toArray(new
GeneralParameterValue[1]));
/* We read the new geotiff file. */
GeoTiffReader readerNew = new GeoTiffReader(outFile);
GridCoverage2D temp3 = (GridCoverage2D)readerNew.read(null);
rasters.add(temp3);
readers.add(readerNew);
temp.dispose(true);
reader.dispose();
// TODO delete original files
// TODO add the creation of overview
}catch(DataSourceException dse){
}catch(IOException ioe){
}catch(CannotCropException cce){
cce.printStackTrace();
}
I tried to simplify the code, just to test, like that :
for(int i = 0; i < files.length; i++){
try{
/* We read the coverage and crop it. */
reader = new GeoTiffReader(files[i], hints);
GridCoverage2D temp = (GridCoverage2D)reader.read(null);
temp.dispose(true);
reader.dispose();
// TODO delete original files
// TODO add the creation of overview
}catch(DataSourceException dse){
}catch(IOException ioe){
}catch(CannotCropException cce){
cce.printStackTrace();
}
But it does not work... Is there somebody who get an idea ?
(I tried to start with reader.dispose(), to put false instead of true....)
Thanks
Thomas
_________________________________________________________________
Vos e-mails vous suivent partout ! Mettez Hotmail sur votre mobile !
http://www.messengersurvotremobile.com/?d=hotmail-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Geotools-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-devel