I often have a bad experience trying to read simple geotiff. To have a more objective view of the situation, I get a very simple image from the test directory of GDAL library and tested it against all our drivers.
Image is attached. Here are its main characteristics (I think they are very common one) :
small_world.tif
size : 400 x 200
Coordinate System : wgs84 (4326)
Metadata : AREA_OR_POINT=AREA
Image Structure Metadata : INTERLEAVE=BAND
3 bands, Block=400x20, Type=Byte, ColorInterp=RGB
I tried to import it with all the image drivers we propose (8 from Open File + ImageRaster Sextante). 3 drivers only could import the image. All others fail throughing a rough java exception. Image Raster don't fail immediately, but it does not display the image and throws NPE if one try to get more information.
List of success/failures and exceptions thrown
Referenced Image (ImageIO[ext],JAI) : OK
ImageIO TIFF Image Reader version 1.0 : OK
ImageIO TIFF Image Reader version 1.1 : OK
Standard TIFF Image Reader
java.lang.IllegalAccessException: class com.vividsolutions.jump.workbench.imagery.ImageryLayerDataset cannot access class com.sun.imageio.plugins.tiff.TIFFImageReaderSpi (in module java.desktop) because module java.desktop does not export com.sun.imageio.plugins.tiff to unnamed module @12405818
at java.base/jdk.internal.reflect.Reflection.newIllegalAccessException(Reflection.java:361)
at java.base/jdk.internal.reflect.Reflection.ensureMemberAccess(Reflection.java:99)
at java.base/java.lang.Class.newInstance(Class.java:579)
at com.vividsolutions.jump.workbench.imagery.ImageryLayerDataset.createFeatureFactory(ImageryLayerDataset.java:236)
at com.vividsolutions.jump.workbench.imagery.ImageryLayerDataset.attachImage(ImageryLayerDataset.java:117)
Referenced Image (JAI TIF)
java.lang.NullPointerException java.lang.NullPointerException at com.sun.media.jai.util.SunCachedTile.<init>(SunCachedTile.java:80)
at com.sun.media.jai.util.SunTileCache.add(SunTileCache.java:257)
at javax.media.jai.OpImage.addTileToCache(OpImage.java:1087)
at javax.media.jai.OpImage.getTile(OpImage.java:1142)
at javax.media.jai.PlanarImage.getData(PlanarImage.java:2085)
at javax.media.jai.RenderedImageAdapter.getData(RenderedImageAdapter.java:158)
at javax.media.jai.ScaleOpImage.computeTile(ScaleOpImage.java:1099)
at com.sun.media.jai.util.SunTileScheduler.scheduleTile(SunTileScheduler.java:904)
at javax.media.jai.OpImage.getTile(OpImage.java:1129)
at com.sun.media.jai.opimage.CropOpImage.getTile(CropOpImage.java:122)
at com.sun.media.jai.opimage.TranslateIntOpImage.getTile(TranslateIntOpImage.java:132) at javax.media.jai.PlanarImage.copyData(PlanarImage.java:2343)
at javax.media.jai.RenderedOp.copyData(RenderedOp.java:2299)
at javax.media.jai.PlanarImage.getAsBufferedImage(PlanarImage.java:2525)
at javax.media.jai.PlanarImage.getAsBufferedImage(PlanarImage.java:2546)
at com.vividsolutions.jump.workbench.imagery.geoimg.GeoImage.paint(GeoImage.java:285)
at com.vividsolutions.jump.workbench.imagery.ReferencedImageStyle.paint(ReferencedImageStyle.java:61)
Referenced Image (JAI TIF) : same error</init>
Buffered Image (common) :
com.vividsolutions.jump.workbench.imagery.ReferencedImageException: java.lang.ArrayIndexOutOfBoundsException: Index 8000 out of bounds for length 8000
at com.vividsolutions.jump.workbench.imagery.graphic.CommonsImage.initImage(CommonsImage.java:112)
at com.vividsolutions.jump.workbench.imagery.graphic.AbstractGraphicImage.computeEnvelope(AbstractGraphicImage.java:122)
at com.vividsolutions.jump.workbench.imagery.graphic.AbstractGraphicImage.getEnvelope(AbstractGraphicImage.java:114)
at com.vividsolutions.jump.workbench.imagery.ImageryLayerDataset.attachImage(ImageryLayerDataset.java:125)
at com.vividsolutions.jump.workbench.imagery.ImageryLayerDataset.attachImage(ImageryLayerDataset.java:106)
at com.vividsolutions.jump.workbench.imagery.ReferencedImageFactoryFileLayerLoader.createImageFeature(ReferencedImageFactoryFileLayerLoader.java:199)
at com.vividsolutions.jump.workbench.imagery.ReferencedImageFactoryFileLayerLoader.open(ReferencedImageFactoryFileLayerLoader.java:102)
at org.openjump.core.ui.plugin.file.open.OpenFileWizard.run(OpenFileWizard.java:164)
GeoTIFF plus (JAI) :
java.lang.NullPointerException java.lang.NullPointerException at com.sun.media.jai.util.SunCachedTile.<init>(SunCachedTile.java:80)
at com.sun.media.jai.util.SunTileCache.add(SunTileCache.java:257)
at javax.media.jai.OpImage.addTileToCache(OpImage.java:1087)
at javax.media.jai.OpImage.getTile(OpImage.java:1142)
at javax.media.jai.PlanarImage.getData(PlanarImage.java:2085)
at javax.media.jai.RenderedImageAdapter.getData(RenderedImageAdapter.java:158)
at javax.media.jai.ScaleOpImage.computeTile(ScaleOpImage.java:1099)
at com.sun.media.jai.util.SunTileScheduler.scheduleTile(SunTileScheduler.java:904)
at javax.media.jai.OpImage.getTile(OpImage.java:1129)
at com.sun.media.jai.opimage.CropOpImage.getTile(CropOpImage.java:122)
at com.sun.media.jai.opimage.TranslateIntOpImage.getTile(TranslateIntOpImage.java:132) at javax.media.jai.PlanarImage.copyData(PlanarImage.java:2343)
at javax.media.jai.RenderedOp.copyData(RenderedOp.java:2299)
at javax.media.jai.PlanarImage.getAsBufferedImage(PlanarImage.java:2525)
at javax.media.jai.PlanarImage.getAsBufferedImage(PlanarImage.java:2546)
at com.vividsolutions.jump.workbench.imagery.geoimg.GeoImage.paint(GeoImage.java:285)
at com.vividsolutions.jump.workbench.imagery.ReferencedImageStyle.paint(ReferencedImageStyle.java:61)</init>
Image Raster (Sextante) : no exception but does not display
NPE Exception comes if one click on layer properties
java.lang.NullPointerException
at com.sun.media.jai.util.SunCachedTile.<init>(SunCachedTile.java:80)
at com.sun.media.jai.util.SunTileCache.add(SunTileCache.java:257)
at javax.media.jai.OpImage.addTileToCache(OpImage.java:1087)
at javax.media.jai.OpImage.getTile(OpImage.java:1142)
at javax.media.jai.PlanarImage.copyData(PlanarImage.java:2343)
at javax.media.jai.RenderedImageAdapter.copyData(RenderedImageAdapter.java:163)
at javax.media.jai.RenderedOp.copyData(RenderedOp.java:2299)
at javax.media.jai.PlanarImage.getAsBufferedImage(PlanarImage.java:2525)
at org.openjump.core.rasterimage.RasterImageIO.loadRasterData(RasterImageIO.java:202)
at org.openjump.core.rasterimage.RasterImageLayer.getRasterData(RasterImageLayer.java:1505)
at org.openjump.core.ui.plugin.raster.RasterImageLayerPropertiesPlugIn.setInfo(RasterImageLayerPropertiesPlugIn.java:444)
at org.openjump.core.ui.plugin.raster.RasterImageLayerPropertiesPlugIn.infoText(RasterImageLayerPropertiesPlugIn.java:248)
at org.openjump.core.ui.plugin.raster.RasterImageLayerPropertiesPlugIn.execute(RasterImageLayerPropertiesPlugIn.java:363) </init>
Hi Michael,
I added a small patch to RasterImageLayer.class (Sextante) which should partially solve the display for tiff loaded via this class.
Not sure about the reason (TIFF drivers? Appling symbology?). I still have Error output whenever I use a pixel querry ([ERROR] 11:11:45.369 Planar (band-sequential) format TIFF is not supported.) which works randomly
Please try OJ 6410
Thanks for your effort Peppe,
I'll try it soon and I'll come back to you.
Michaël
Related
Bugs: #498
Hi Michael,
I confirm newer OJ MB can load and display simple geotiff.
The changes I did:
a) TiFFUtils class. Method getRenderedOp(File tiffFile) which was using JAI.create method to load a file. I added as main method GeoReferencedRaster.getRenderedOp which seems more robust and able to open more tiff (and more image types) files.
b) RasterImageLayer.createImage pointed to the method RasterImageLayer.stretchImageValuesForDisplay() . This method rebuilds the BufferedImageLayer to display on the view. It was created by Alberto De Luca to give the right colors (BW and symbology) for monoband rasters but I observed that sometimes it fails to display raster which have more than 3 bands (4th the transparency).
The change I did: In case stretchImageValuesForDisplay() fails, it returns the original loaded BufferedImageLayer
I still cannot solve problems connected to the tool Raster>pixel inspection (method RasterImageLayer.getCellValue...) that return a null poiter exception on your file
Since I have problems to display Aster tiff files, possibily due to the precence of overviews, I am considering to add a plugin to convert a file image (TIFF in this case) directly without loading into OJ view
On 9/4/2020 9:01, Giuseppe Aruta wrote:
can you attach an Aster Tiff sample?.. ede
I attached the Aster DEM tif file.
Once loaded into OpenJUMP, to display it, click on "Zoom to layer"
Then try to use the tools Raster>Pixel inspection or Raster>Profile
The output is always "0.0"
Peppe
i see. so it assentially loads and shows but the additional pixel data is missing. ok, can't help with that. maybe you want to take a peek how other JUMPSs/Java apps access those and implement it in OJ? good to have sample online as well.
if it used to work earlier try to identify the patchset that broke it and fix that.
..ede
On 9/4/2020 11:40, Giuseppe Aruta wrote:
Related
Bugs: #498
Just tested again with r6423.
Loading image with Open > File did not change
There is still the same drivers working and the same drivers throwing different exceptions with small_world tif
On the other hand, Open > Raster Image (Sextante) now loads and display the image correctly ;-)
Aster DEM tif file is also correctly displayed.
After images have been loaded with Raster Image (Sextante), Info tool throws an NPE, either on the small_world.tiff or on the Aster DEM (where ever we click in the image extent)
Anyway, thank for your fix.
I'll do some more tests. I don't think we can support every kind of raster, but maybe we can try to return more informative messages when a problem occurs.
If you agree I will keep this ticket open for OpenJUMP 2.0
@edso
won't be fixed soonish, tag it accordingly
wrt. Commons Imaging - tested with commons-imaging-1.0-alpha2.jar the issue still remains.
i logged a bug in their tracker, let's see how it pans out
https://issues.apache.org/jira/projects/IMAGING/issues/IMAGING-265?filter=allopenissues
The problem is due to a TIFF format that is not supported by Commons-Imaging. I posted some notes to your bug report. I completed a code change and the fix is in the pipeline.
Thanks for the test file. It helped a lot. If you have others (particular examples using a tile-organization rather than strips), I'd welcome them.
wrt. to Standard TIFF Image reader from sun. since jdk9 or later it needs
--add-exports java.desktop/com.sun.imageio.plugins.tiff=ALL-UNNAMED
to access the specific imageio package.
added that to our startup scripts in rev 6427
https://sourceforge.net/p/jump-pilot/code/6427/
OpenJUMP 6430 - (Sextante) RasterImage. Almost solved reading pixel data (Info tool , pixel inspection and raster profile) for test image small_word.tif (not for Aster dem file).
Removed also warnings substituting GeoReferencedRaster.getImage() method to read PlanarImage of TIFF (instead of JAI.create("fileload"..)
Last edit: Giuseppe Aruta 2020-09-06
(Sextante) RasterImage. I had to revert some changes I did in these days. Mostly connected to cell query. The reason: Roberto Rossi, from Univ, of Padua, who worked as my tester found some blurring on display discrete DEMs (Dem with classes) and the cell query was quite slow and displaying wrong info (possibily due to a delay on the reading process, the read values were "jumping" from the original position to the click point. To summerize with these last modification
a) OJ opens and display both test tiff (small_earth.tif and AsterDEM). In some cases, large file, user needs to zoom one or two times to the layer to accellerate the display process. If I load several big files and then I load AsterDEM, this is not displayed (the reasons? Memory, ImageIO readers?). Blurring was solved
b) info tools on the cell finally works well on AsterDEM fine, they don't work fine with small_earth.tif).
c) in both cases I cannot extract a part of the image (draw fence-extract part of image). I didn't explore the reason. AFAIR this tool at the beginning had problems when Alberto de Luca changed RasterImage framework.
I think I will stop making changes. Roberto goes on to do few test as his course (where he uses OJ) starts the 1 of October - to late to move to OJ 1.16.
The essential change on the Raster Framework
I tried to handle errors in a more friendly way in r6443, but it seems that the best improvement wrt this ticket has been made by changing old jai libray by the new oss version. Thanks EDE.
There is still two drivers failing in reading the small_world tiff image. One of them is Apache Commons Imaging. It may be worthwhile keeping this driver if we find images that only this driver can read. Otherwise...
Peppe also fixed Info tools (thanks) and report some more problems.
Maybe we should close this ticket and open more specific ones about remaining problems. What do you think ?
On 12.09.2020 11:31, michael michaud wrote:
my patchset unfortunately disabled GeoImage framework with forced loaders so all variants actually used the first loader, which is the new oss one. just fixed that in r6446. so please retest.
you can check which loader was actually used in the ImageLayerManager (layer context menu).
as i wrote above. there is an open ticket in their bug tracker. the latest version, which we include now, still chokes on it.
that's my reasoning as well. they support some exotic formats.
let's wait for the monoband issue fix and close then. ..ede
OK, I see,
The drivers wich did not work still does not work :-(
Will do some more test tomorrow.
Anyway, I spent several days trying to catch an error to return a more informative message to the user, but without success
Using the apache driver, I get
[ERROR] 2020-09-13_00:07:45.190 Index 8000 out of bounds for length 8000
That's OK, I can catch it and report it.
When using the jai drivers (either TIFF or XTIFF), I just catch a NPE, but looking at the log file, I can see,
the same error as with apache (Index 8000 out of bounds for length 8000 ) and before that, an IOException :
java.io.IOException: Planar (band-sequential) format TIFF is not supported.
I tried to catch those error to return them in the Error dialog instead of the NPE but without success.
I'm not sure it is very useful, but I'm quite frustrated because I can't understand when this error is logged and why I can't catch it through the UI. If you have an idea, I would be very interested.
Miichaël
Related
Bugs: #498
Sextante Raster. we lost the ability (version OJ 6443) to load TIFF DEM (mono band rasters).
I tested with several TIFF DEM, including the one I attached here. None is load.
AFAIR we had the same problem when we moved to imageIO-ext 1.1.13 to 1.1.16 (OJ 1.15). So we had to downgrade to imageio-ext-tiff-1.1.13.jar.
I tried to cancel imageio-ext-tiff-1.3.2.jar and substitute it with imageio-ext-tiff-1.1.13.jar on version OJ 6443 (keeping the others to ver. 1.3.2) and everything goes fine.
I suggest to keep this bug ticket open until we solve this problem
This is the message of error that I recognized:
java.lang.ClassCastException: [B cannot be cast to [Ljava.lang.String;
at it.geosolutions.imageio.plugins.tiff.TIFFField.getAsString(TIFFField.java:1164)
at it.geosolutions.imageioimpl.plugins.tiff.TIFFImageReader.initializeFromMetadata(TIFFImageReader.java:1286)
at it.geosolutions.imageioimpl.plugins.tiff.TIFFImageReader.seekToImage(TIFFImageReader.java:831)
at it.geosolutions.imageioimpl.plugins.tiff.TIFFImageReader.seekToImage(TIFFImageReader.java:788)
at it.geosolutions.imageioimpl.plugins.tiff.TIFFImageReader.getWidth(TIFFImageReader.java:1046)
at org.openjump.core.rasterimage.OverviewsUtils.addOverviews(OverviewsUtils.java:65)
at org.openjump.core.rasterimage.OverviewsUtils.getOverviews(OverviewsUtils.java:45)
at org.openjump.core.rasterimage.RasterImageIO.loadImage(RasterImageIO.java:142)
at org.openjump.core.rasterimage.RasterImageLayer.reLoadImage(RasterImageLayer.java:548)
at org.openjump.core.rasterimage.RasterImageLayer.createImage(RasterImageLayer.java:385)
at org.openjump.core.rasterimage.RasterImageRenderer.renderHook(RasterImageRenderer.java:107)
Last edit: Giuseppe Aruta 2020-09-12
I would like to find a solution with I imageio-ext 1.3.2. It seems to work faster and to use less memory. Otherwise I am OK to downgrade to the last working version (1.1.13)
thanks for testing Peppe. i actually made sure that the monoband geotiff you sent once me would properly load after the switch still. talking about the attached.
wrt. to closing this ticket - yeah let's clear up the monoband issue and close then.
I see that there is a newer version OJ 6344, I will test it.
Just to check it is not a OS problem, I use Ubuntu with OpenJDK 1.8