Ciao Milton,
I downloaded and checked your image. A few annotations:

- here is part of the gdalinfo

Driver: MrSID/Multi-resolution Seamless Image Database (MrSID)
Files: 161866.sid
Size is 8000, 8000
Coordinate System is:
PROJCS["NAD83 / Massachusetts Mainland",
    GEOGCS["NAD83",
        DATUM["North_American_Datum_1983",
            SPHEROID["GRS 1980",6378137,298.2572221010002,
                AUTHORITY["EPSG","7019"]],
            AUTHORITY["EPSG","6269"]],
        PRIMEM["Greenwich",0],
        UNIT["degree",0.0174532925199433],
        AUTHORITY["EPSG","4269"]],
    PROJECTION["Lambert_Conformal_Conic_2SP"],
    PARAMETER["standard_parallel_1",42.68333333333333],
    PARAMETER["standard_parallel_2",41.71666666666667],
    PARAMETER["latitude_of_origin",41],
    PARAMETER["central_meridian",-71.5],
    PARAMETER["false_easting",200000],
    PARAMETER["false_northing",750000],
    UNIT["metre",1,
        AUTHORITY["EPSG","9001"]],
    AUTHORITY["EPSG","26986"]]
Origin = (157000.000000000000000,870000.000000000000000)
Pixel Size = (0.500000000000000,-0.500000000000000)
  IMAGE__WKT=PROJCS["NAD83 / Massachusetts Mainland",GEOGCS["NAD83",DATUM["North
_American_Datum_1983",SPHEROID["GRS 1980",6378137,298.2572221010002,AUTHORITY["E
PSG","7019"]],AUTHORITY["EPSG","6269"]],PRIMEM["Greenwich",0],UNIT["degree",0.01
74532925199433],AUTHORITY["EPSG","4269"]],PROJECTION["Lambert_Conformal_Conic_2S
P"],PARAMETER["standard_parallel_1",42.68333333333333],PARAMETER["standard_paral
lel_2",41.71666666666667],PARAMETER["latitude_of_origin",41],PARAMETER["central_
meridian",-71.5],PARAMETER["false_easting",200000],PARAMETER["false_northing",75
0000],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AUTHORITY["EPSG","26986"]]
Corner Coordinates:
Upper Left  (  157000.000,  870000.000) ( 72d 1'10.82"W, 42d 4'45.22"N)
Lower Left  (  157000.000,  866000.000) ( 72d 1'9.76"W, 42d 2'35.57"N)
Upper Right (  161000.000,  870000.000) ( 71d58'16.79"W, 42d 4'45.97"N)
Lower Right (  161000.000,  866000.000) ( 71d58'15.83"W, 42d 2'36.32"N)
Center      (  159000.000,  868000.000) ( 71d59'43.30"W, 42d 3'40.78"N)
Band 1 Block=1024x128 Type=Byte, ColorInterp=Red
  Minimum=19.000, Maximum=234.000, Mean=140.080, StdDev=27.898
  Overviews: 4000x4000, 2000x2000, 1000x1000, 500x500, 250x250, 125x125, 63x63,
32x32
Band 2 Block=1024x128 Type=Byte, ColorInterp=Green
  Minimum=12.000, Maximum=233.000, Mean=125.267, StdDev=26.812
  Overviews: 4000x4000, 2000x2000, 1000x1000, 500x500, 250x250, 125x125, 63x63,
32x32
Band 3 Block=1024x128 Type=Byte, ColorInterp=Blue
  Minimum=20.000, Maximum=233.000, Mean=107.674, StdDev=24.172
  Overviews: 4000x4000, 2000x2000, 1000x1000, 500x500, 250x250, 125x125, 63x63,
32x32

This means, 3 bands, size 8k*8k at the highest res with tiling of 1024*128.
By default the Imageio-ext gdal plugin does not use JAI ImageRead but
tries to do a full read using the ImageReader.
The error you are seeing is the underlying JVM running out of direct
memory (fast native mapped heap), see here [1] for reference.

If you want to be able to read and reproject larger raster through
imageio-ext with low memory footprint. You can do something like this:

        // get a reader
        final BaseGridCoverage2DReader reader = new MrSIDReader(TestData.file(
                this, fileName));

        final ParameterValue tilesize = (ParameterValue)
((BaseGDALGridFormat)
reader.getFormat()).SUGGESTED_TILE_SIZE.createValue();
        tilesize.setValue("512,512");
        
       final ParameterValue useJaiRead = (ParameterValue)
((BaseGDALGridFormat)
reader.getFormat()).USE_JAI_IMAGEREAD.createValue();
       useJaiRead.setValue(true);

       final ParameterValue mt = (ParameterValue)
((BaseGDALGridFormat)
reader.getFormat()).USE_MULTITHREADING.createValue();
       mt.setValue(true);               

        GridCoverage2D gc = (GridCoverage2D) reader.read(new
GeneralParameterValue[] { tilesize, useJaiRead,mt });


This does:

1> retiling on read to have better tile size
2> use JAI ImageRead instead of doing a plain read on the ImageReader
3> use multithreading capabilities of our ImageReader and our
ImageReadMT operation. You can  control the number of tile through
JAI.getDefaultInstance().getTileScheduler().setParallelism(numTile);

With the above setting I have been able to reproject the image with
these low footprint settings :
-XX:MaxDirectMemorySize=8M  -Xmx16M

Ciao,
Simone.


On Tue, Oct 7, 2008 at 8:34 PM, Milton Jonathan
<[EMAIL PROTECTED]> wrote:
> Hello there
>
> I've been playing around reprojecting imagery and found that everything
> works fine with tiny MrSID files. However, when attempting to read a
> larger file (e.g.,
> ftp://data.massgis.state.ma.us/pub/wave/coqhsid/east/161866.sid), I get
> an "OutOfMemoryError: Direct buffer memory" exception.
>
> The reason is probably because I am trying to read everything into
> memory (using GridCoverageReader.read(null), which by the way is
> deprecated). So, what would be the current suggested way of doing this,
> so that I simply specify the reprojection operation without having to
> read everything? I am aware that the Coverage API is going to change,
> but it would still be good to know how to do things right with the
> current library available.
>
> My current code goes as follows (using GeoTools version 2.5-RC1):
>
>
> File file = new File("D:\\data\\source.sid");
> File destFile = new File("D:\\data\\dest.tif");
>
> AbstractGridFormat gridFormat =
> (AbstractGridFormat)GridFormatFinder.findFormat(file);
> if (gridFormat instanceof UnknownFormat)
>     throw new FactoryException("Cannot find a reader for file " + file);
>
> GridCoverageReader reader = gridFormat.getReader(file, hints);
> GridCoverage2D coverage = (GridCoverage2D) reader.read(null);
>
> CoordinateReferenceSystem sourceCRS =
> coverage.getCoordinateReferenceSystem();
> CoordinateReferenceSystem targetCRS = CRS.decode("EPSG:4326");
>
> GridCoverage2D coverageTransf = (GridCoverage2D)
> Operations.DEFAULT.resample(coverage, targetCRS);
>
> GeoTiffWriter writer = new GeoTiffWriter(destFile);
> writer.write(coverageTransf, null);
>
>
>
> Thanks!
> Milton
>
> --
>
> Milton Jonathan
> Grupo GIS e Meio Ambiente
> Tecgraf/PUC-Rio
> Tel: +55-21-3527-2502
>
>
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
> Build the coolest Linux based applications with Moblin SDK & win great prizes
> Grand prize is a trip for two to an Open Source event anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> _______________________________________________
> Geotools-gt2-users mailing list
> Geotools-gt2-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
>



-- 
-------------------------------------------------------
Eng. Simone Giannecchini
GeoSolutions S.A.S.
Owner - Software Engineer
Via Carignoni 51
55041  Camaiore (LU)
Italy

phone: +39 0584983027
fax:      +39 0584983027
mob:    +39 333 8128928


http://www.geo-solutions.it
http://www.geo-solutions.it/simone.giannecchini
http://www.linkedin.com/in/simonegiannecchini

-------------------------------------------------------

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Geotools-gt2-users mailing list
Geotools-gt2-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to