What is the best approach to reading the values from a big raster in geotiff format?

المشرف العام

Administrator
طاقم الإدارة
I am reading values from large rasters in geotiff format. The size is around 30GB and there is only one band. I'm using geotools to do that. I did some experiments on reading the whole raster to find the best way to do this and realized that performance varies greatly. This is code I used:

file file = new File(path);GridCoverage2DReader reader = new GeoTiffReaderCached(file);GridCoverage2D coverage;ParameterValue policy = AbstractGridFormat.OVERVIEW_POLICY.createValue();policy.setValue(OverviewPolicy.IGNORE);ParameterValue gridsize = AbstractGridFormat.SUGGESTED_TILE_SIZE.createValue();gridsize.setValue("512,512");ParameterValue useJaiRead = AbstractGridFormat.USE_JAI_IMAGEREAD.createValue();useJaiRead.setValue(true);try { coverage = this.reader.read(new GeneralParameterValue[] { policy, useJaiRead}); } catch (IOException e) { e.printStackTrace(); }RandomIter iter = RandomIterFactory.create(img, null);In the experiments, I change between reading row by row or tile by tile and change between specifying a value for suggested tile like (512,512) or just leave it as is (the tile will be a row by default). Here is the four different ways and their timings:

  1. With no tile suggested; reading values row by row: timing (sec) = 328.
  2. With no tile suggested; reading values tile by tile: timing (sec) = 42334 (the worst).
  3. With tile suggested (512,512); reading values row by row (ignoring the tiles): timing (sec) = 4295.
  4. With tile suggested (512,512); reading values tile by tile: timing (sec) = 3409.
The best performance was for the first way. I wonder why?



أكثر...
 
أعلى