Hi Bruce,
The issue with InputStreams currently has an outstanding pull request here:
https://github.com/geotools/geotools/pull/1341
Hopefully will be merged soon.
As someone who has toyed with this (no code to share right now
unfortunately), my recommendation is just to use one of the various S3 FUSE
implementations. In my brief testing, Goofys is the fastest, but does
sacrifice some filesystem-y capabilities:
https://github.com/kahing/goofys
but there are numerous implementations. I've done GeoTiff off of one of
these and it seems to work fine. It has the bonus of needing zero extra
code and being easily extensible to things like ImageMosaic or any other
raster format.
If you want to head down the road of actually modifying the GeoTiffReader
to work via S3, you'll need to look at creating a custom ImageInputStream
implementation and then either the various tweaks to GeoServer/GeoTools
required to get S3:// URLs to work seamlessly, or creating your own
GridFormat implementation that works off of S3. The latter is what I've
done in experimenting with this.
Cheers
On Thu, Dec 15, 2016 at 7:56 AM, Jim Hughes <[email protected]> wrote:
> Hi all,
>
> Broadly, I was interested in a similar issue of having GeoServer serve up
> GeoTiffs from HDFS. I wrote about what I had to do here (1) on the
> GeoServer list.
>
> I'm guessing the error here has to do with an issue in handling
> InputStreams. The GeoTiff reader can also work with ImageInputStreams.
> That's why I suggested on your SO question (2) to wrap the FileInputStream
> in a MemoryCacheImageInputStream. Have you had a chance to try that out?
>
> Cheers,
>
> Jim
>
> 1. http://osgeo-org.1560.x6.nabble.com/Reading-GeoTiffs-
> from-HDFS-td5261637.html
> 2. http://stackoverflow.com/questions/41103428/geotiffreader-and-
> inputfilestream
>
>
> On 12/15/2016 10:39 AM, Bruce Ikelheimer wrote:
>
> 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
> [email protected]https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
>
>
>
> ------------------------------------------------------------
> ------------------
> 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
>
>
------------------------------------------------------------------------------
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