[geotk] Change the CRS of an existing GridCoverage2D

Fabien Carrion fabien.carrion at gmail.com
Sun Feb 27 16:42:20 EST 2011


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hello Martin,

On 02/26/2011 04:36 PM, Martin Desruisseaux wrote:
> 
> Le 25/02/11 22:52, Fabien Carrion a écrit :
>> org.opengis.geometry.MismatchedDimensionException: Argument
>> "gridRange" has 2 dimensions, while 3 was expected.
>>
>> (...snip...)
>>
>> I have
>> Dimensions RenderedSampleDimension("Albedo":[6.0 ? 79.3 %])
>>      GeophysicsCategory("Albedo":[6.0 ... 79.30000305175781])
>>      GeophysicsCategory("No data":[NaN(0...0)])
>>
>> Where can I find the dimension which is missing?
> 
> The dimension that the exception is talking about are CRS dimensions,
> not "sample dimension". I admit this is not obvious given the
> "dimension" and "sample dimension" names...
> 
> I would guess that the CRS associated to your data is 3 dimensional
> (where the third dimension is probably time) while some other argument
> is two dimensional. Could you post the output of the following please:
> 
>     System.out.println(crs);
>     System.out.println(gridToCRS);
> 
> Maybe a snipset of your code would also help.
> 

With those two print I get

crs GEOGCS["WGS 84",
  DATUM["WGS_1984",
    SPHEROID["WGS 84", 6378137.0, 298.257223563, AUTHORITY["EPSG","7030"]],
    AUTHORITY["EPSG","6326"]],
  PRIMEM["Greenwich", 0.0, AUTHORITY["EPSG","8901"]],
  UNIT["degree", 0.017453292519943295],
  AXIS["Longitude", EAST],
  AXIS["Latitude", NORTH],
  AUTHORITY["EPSG","4326"]]
gridToCRS PARAM_MT["Affine",
  PARAMETER["num_row", 4],
  PARAMETER["num_col", 4],
  PARAMETER["elt_0_0", 0.09000000357627869],
  PARAMETER["elt_0_3", 215.86099243164062],
  PARAMETER["elt_1_1", -0.07699999958276749],
  PARAMETER["elt_1_3", 82.258999414742],
  PARAMETER["elt_2_2", �],
  PARAMETER["elt_2_3", �]]


In my code I get the gridcoverage from the NetcdfReader I slightly
modified and then I recreate a new gridcoverage based on the previous
one to add the color to the image.

Then I do
            String wkt = "GEOGCS[\"WGS 84\"," +
                         "        DATUM[\"WGS_1984\"," +
                         "              SPHEROID[\"WGS 84\", 6378137.0,
298.257223563, AUTHORITY[\"EPSG\",\"7030\"]]," +
                         "              AUTHORITY[\"EPSG\",\"6326\"]]," +
                         "        PRIMEM[\"Greenwich\", 0.0,
AUTHORITY[\"EPSG\",\"8901\"]]," +
                         "        UNIT[\"degree\", 0.017453292519943295]," +
                         "        AXIS[\"Longitude\", EAST]," +
                         "        AXIS[\"Latitude\", NORTH]," +
                         "        AUTHORITY[\"EPSG\",\"4326\"]]";

            CoordinateReferenceSystem targetCRS = CRS.parseWKT(wkt);

            GridCoverage2D oldCoverage = coverage;

            System.out.println("crs " + targetCRS);
            System.out.println("gridToCRS " +
oldCoverage.getGridGeometry().getGridToCRS());
            coverage = factory.create(oldCoverage.getName(),
                                      oldCoverage.getRenderedImage(),
                                      targetCRS,

oldCoverage.getGridGeometry().getGridToCRS(),
                                      oldCoverage.getSampleDimensions(),
                                      null,
                                      null);


            coverage = coverage.view(ViewType.RENDERED);
            coverage.show();


I am not very good at writting CoordinateReferenceSystem, is there any
good documentation/book on it?

Thanks

- -- 
Fabien Carrion

()  Campagne du ruban ASCII -- Contre les mails en html
/\  contre les pieces-jointes Microsoft
Web: http://fabien.carrion.free.fr/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk1qxTUACgkQTe/bvZWuSM/p4ACgj1wk6NcgRQPeuxspg57lDaZY
9wQAoMU/B0REZm/bh9SRnW1YBpDX50I0
=/U42
-----END PGP SIGNATURE-----


More information about the Geotoolkit mailing list