I want to bring back an old topic, because I did not see that it was
finally solved in a way I can use. I want to be able to load in a geotiff
file from a server (an AWS s3 bucket in particular). I am up for any
method, but I tried to simply pass GeoTiffReader an input stream rather
than a file. I am using Geotools 16 (built up with Maven with Eclipse).
When I create the reader with the following lines:
FileInputStream geotiffFile = new
FileInputStream("location_of_tiff\\tiffFile.tif");
GridCoverage2DReader tiffReader = new GeoTiffReader(geotiffFile);
the class is generated no problem. I can read in the coordinate system, the
size, the number of bands, everything...except the actual data. The
following read line:
rasterData =
tiffReader.read(null);
causes the following (partial) stack.
Caused by: javax.imageio.IIOException: I/O error reading header!
at
it.geosolutions.imageioimpl.plugins.tiff.TIFFImageReader.readHeader(TIFFImageReader.java:458)
at
it.geosolutions.imageioimpl.plugins.tiff.TIFFImageReader.locateImage(TIFFImageReader.java:465)
at
it.geosolutions.imageioimpl.plugins.tiff.TIFFImageReader.seekToImage(TIFFImageReader.java:589)
at
it.geosolutions.imageioimpl.plugins.tiff.TIFFImageReader.getImageTypes(TIFFImageReader.java:1104)
at
javax.imageio.ImageReader.getRawImageType(ImageReader.java:681)
at
com.sun.media.jai.imageioimpl.ImageReadOpImage.layoutHelper(ImageReadOpImage.java:228)
at
com.sun.media.jai.imageioimpl.ImageReadOpImage.<init>(ImageReadOpImage.java:473)
at
com.sun.media.jai.imageioimpl.ImageReadCRIF.create(ImageReadCRIF.java:309)
... 15 more
Caused by: java.io.EOFException
at
javax.imageio.stream.ImageInputStreamImpl.readShort(ImageInputStreamImpl.java:229)
at
javax.imageio.stream.ImageInputStreamImpl.readUnsignedShort(ImageInputStreamImpl.java:242)
at
it.geosolutions.imageioimpl.plugins.tiff.TIFFImageReader.readHeader(TIFFImageReader.java:404)
... 22 more
I have set this up to access a local file on my machine, but I get the
exact same errors if I access the file on an s3 bucket. If, instead of the
FileInputStream, I pass in a File, it works fine with no problems. I feel I
am so close, but my noob status means I have no idea how to fix this!!!
----------------------
Bruce J. Ikelheimer, Ph.D.
Acoustic Analytics
89 Saint Dunstan’s Rd. | Asheville, NC 28803
(703) 403-9842
www.AcousticAnalytics.com
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
GeoTools-GT2-Users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users