From: Peter B. <pet...@ya...> - 2015-01-09 14:47:36
|
Well, I give up :-( I decompiled the RasterLayerRequest class that was in the 10.8 release and when I added it to my project, I got a past the NPE but ended up with a totally different error (negative array index). I ended up converting the ESRI grid to a geotiff using gdal_translate and now I'm able to process the file using the org.geotools.gce.geotiff.GeoTiffReader. Peter From: Peter Borissow <pet...@ya...> To: Geotools-gt2-users <geo...@li...> Sent: Wednesday, January 7, 2015 6:50 AM Subject: Re: Error Reading ESRI ArcGrid File I have posted the question on the gis stackexchange: http://gis.stackexchange.com/questions/128350/error-reading-esri-arcgrid-file-using-geotools Follow-up questions: (1) What version of GDAL should I use for the GeoTools 10.8 release? In my tests, I am using the latest and greatest (version 1.11 x64). Is GeoTools 10.x compatible with this release? (2) Where is the source code for org.geotools.coverageio.RasterLayerRequest used in the GeoTools 10.8 release? On github, line 902 of RasterLayerRequest.java in the 10.x source code is an empty string that couldn't possibly cause a NPE: https://github.com/geotools/geotools/blob/10.x/modules/plugin/imageio-ext-gdal/src/main/java/org/geotools/coverageio/RasterLayerRequest.java From: Peter Borissow <pet...@ya...> To: Geotools-gt2-users <geo...@li...> Sent: Tuesday, January 6, 2015 6:13 PM Subject: Error Reading ESRI ArcGrid File I have a raster file in ESRI ArcGrid format (e.g. hdr.adf). I would like to run some analysis using GeoTools. I've never used the GDAL plugin before and I'm having a few problems out of the gates. Specifically, I'm getting a null pointer exception when I try to read the ArcGrid file. I can instantiate the AIGReader just fine and I get the correct values when I check the bounds but the BaseGDALGridCoverage2DReader.read() method is throwing an error. Here's the code: BaseGDALGridCoverage2DReader reader = new AIGReader(file); System.out.println(reader.getSource()); System.out.println(reader.getOriginalEnvelope()); System.out.println(reader.getOriginalGridRange()); GridCoverage2D gc = (GridCoverage2D) reader.read(null); The read method throws the following Exception: Exception in thread "main" java.lang.NullPointerException at org.geotools.coverageio.RasterLayerRequest.setBaseParameters(RasterLayerRequest.java:902) at org.geotools.coverageio.RasterLayerRequest.<init>(RasterLayerRequest.java:206) at org.geotools.coverageio.BaseGridCoverage2DReader.read(BaseGridCoverage2DReader.java:400) I tried passing in an array of GeneralParameterValue but I still get a null pointer exception. Example: ParameterValue<OverviewPolicy> policy = AbstractGridFormat.OVERVIEW_POLICY.createValue(); policy.setValue(OverviewPolicy.IGNORE); ParameterValue<String> gridsize = AbstractGridFormat.SUGGESTED_TILE_SIZE.createValue(); ParameterValue<Boolean> useJaiRead = AbstractGridFormat.USE_JAI_IMAGEREAD.createValue(); useJaiRead.setValue(true); reader.read(new GeneralParameterValue[]{policy, gridsize, useJaiRead}); I'm using Java 1.6 so I'm stuck with GeoTools 10.8. Any suggestions? Thanks,Peter |