Utilizo la API GeoTools para leer y renderizar un archivo JPEG GeoTiff comprimido:
AbstractGridFormat format = new GeoTiffFormat();
format.accepts(rasterFile);
//this is a bit hacky but does make more geotiffs work
Hints hints = new Hints(Hints.FORCE_LONGITUDE_FIRST_AXIS_ORDER, Boolean.TRUE);
// InputStream stream = new BufferedInputStream(new FileInputStream(rasterFile), 40*1024);
reader = format.getReader(rasterFile, hints);
// Initially display the raster in greyscale using the
// data from the first image band
Style rasterStyle = createGreyscaleStyle(1);
// Connect to the shapefile
FileDataStore dataStore = FileDataStoreFinder.getDataStore(shpFile);
SimpleFeatureSource shapefileSource = dataStore
.getFeatureSource();
// Create a basic style with yellow lines and no fill
Style shpStyle = SLD.createPolygonStyle(Color.YELLOW, null, 0.0f);
// Set up a MapContent with the two layers
final MapContent map = new MapContent();
map.setTitle("ImageLab");
Layer rasterLayer = new GridReaderLayer(reader, rasterStyle);
map.addLayer(rasterLayer);
El problema es que para los archivos GeoTiff de mayor tamaño (por ejemplo, 30 MB) la representación tarda un par de segundos en un equipo actualizado, lo que resulta especialmente problemático si el usuario utiliza funciones como el zoom.
¿Hay alguna manera de utilizar la API de forma diferente para acelerar el proceso? He hecho un perfil aproximado pero sólo he visto que el renderizador trabaja un par de segundos si se refresca la imagen.
El GeoTiff se creó con gdal
gdal_translate -of GTiff -co COMPRESS=JPEG -co PHOTOMETRIC=YCBCR -co TILED=yes -a_srs EPSG:4326'