I am trying to 1) Read an NZMG raster, reproject it to NZTM and write it out:
try {
      File rasterFile = new File("TestData/heathcote_200_depth.png");
      WorldImageFormat format = (WorldImageFormat)
GridFormatFinder.findFormat( rasterFile );
      AbstractGridCoverage2DReader reader = format.getReader(rasterFile);
      GridCoverage2D myGridCov = reader.read(null);
      GridCoverage2D reprojected = (GridCoverage2D)
Operations.DEFAULT.resample(myGridCov, CRS.decode("EPSG:2193));
      WorldImageWriter wir = new WorldImageWriter(new
File("TestData/heathcote_NZTM.png"));
      wir.write(reprojected, null);
 } catch (Exception e) {
   ……
 }

IN this case the code just hangs after the reproduction. No error messages,
nothing. It just sits there till I hace to kill it.


and 2) Read an NZTM raster, reproject it to NZMG and write it out:

try {
      File rasterFile = new
File("TestData/mis100yearmpdcc_maxdepth_NZMG.tif");
      GeoTiffFormat format = (GeoTiffFormat)GridFormatFinder.findFormat(
rasterFile );
      AbstractGridCoverage2DReader reader = format.getReader(rasterFile);
      GridCoverage2D myGridCov = reader.read(null);
      GridCoverage2D reprojected = (GridCoverage2D)
Operations.DEFAULT.resample(myGridCov, CRS.decode("EPSG:27200"));
      GeoTiffWriter wir = new GeoTiffWriter(new
File("TestData/miss100.tif"));
      ParameterValueGroup params = format.getWriteParameters();
      GeneralParameterValue[] wps = (GeneralParameterValue[])
params.values().toArray(new GeneralParameterValue[1]);
      wir.write(myGridCov, wps);
} catch (Exception e) {
……….
}

In this case, I get the error message

java.lang.IllegalArgumentException: Unable to map
projectionNew_Zealand_Map_Grid at
org.geotools.coverage.grid.io.imageio.geotiff.CRS2GeoTiffMetadataAdapter.parseCoordinateProjectionTransform(CRS2GeoTiffMetadataAdapter.java:739)
at
org.geotools.coverage.grid.io.imageio.geotiff.CRS2GeoTiffMetadataAdapter.parseProjection(CRS2GeoTiffMetadataAdapter.java:290)
at
org.geotools.coverage.grid.io.imageio.geotiff.CRS2GeoTiffMetadataAdapter.parseProjCRS(CRS2GeoTiffMetadataAdapter.java:241)
at
org.geotools.coverage.grid.io.imageio.geotiff.CRS2GeoTiffMetadataAdapter.parseCoordinateReferenceSystem(CRS2GeoTiffMetadataAdapter.java:176)
at org.geotools.gce.geotiff.GeoTiffWriter.write(GeoTiffWriter.java:251) at
riskscape.map.internal.render.DataImageTest.testReprojectFileNZTMToNZMG(DataImageTest.java:119)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597) at
org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
at
org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at
org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
at
org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263) at
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
at
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231) at
org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60) at
org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229) at
org.junit.runners.ParentRunner.access$000(ParentRunner.java:50) at
org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222) at
org.junit.runners.ParentRunner.run(ParentRunner.java:300) at
org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
  

Any ideas on how to proceed? 
Thank you
Gaby



--
View this message in context: 
http://osgeo-org.1560.x6.nabble.com/Cannot-save-reprojected-georeferenced-raster-to-file-tp5068102.html
Sent from the geotools-gt2-users mailing list archive at Nabble.com.

------------------------------------------------------------------------------
See everything from the browser to the database with AppDynamics
Get end-to-end visibility with application monitoring from AppDynamics
Isolate bottlenecks and diagnose root cause in seconds.
Start your free trial of AppDynamics Pro today!
http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
_______________________________________________
GeoTools-GT2-Users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to