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

------------------------------------------------------------------------------
Dive into the World of Parallel Programming! The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net
_______________________________________________
GeoTools-GT2-Users mailing list
GeoTools-GT2-Users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to