<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:"Segoe UI";
panose-1:2 11 5 2 4 2 4 2 2 3;}
@font-face
{font-family:Consolas;
panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri",sans-serif;
mso-fareast-language:EN-US;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:#0563C1;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:#954F72;
text-decoration:underline;}
code
{mso-style-priority:99;
font-family:"Courier New";}
span.E-postmall17
{mso-style-type:personal-compose;
font-family:"Calibri",sans-serif;
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri",sans-serif;
mso-fareast-language:EN-US;}
@page WordSection1
{size:612.0pt 792.0pt;
margin:70.85pt 70.85pt 70.85pt 70.85pt;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="SV" link="#0563C1" vlink="#954F72">
<div class="WordSection1">
<p class="MsoNormal"><span lang="EN-US">I've used gdalwarp.exe to project a tif-file from EPSG:4326 to EPSG:32635 and storing it in the PNG-format:<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> gdalwarp.exe -dstalpha -t_srs EPSG:32635 -s_srs EPSG:4326 -if GTiff -of PNG -et 0.125 -r cubicspline -co COMPRESS=LZW -co WORLDFILE=YES H:\somlos_8.tif H:\trans32635.png<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">Then I try to read that PNG_file in JAVA with GDAL:<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> import org.geotools.coverage.grid.GridCoverage2D;<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> import org.geotools.coverage.grid.io.AbstractGridFormat;<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> import org.geotools.coverage.grid.io.GridCoverage2DReader;<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> import org.geotools.coverage.grid.io.GridFormatFinder;<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> import org.geotools.factory.Hints;<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> import org.geotools.gce.geotiff.GeoTiffFormat;<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> <o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> public class Test {<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> public Test() {
<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> </span>AbstractGridFormat format = GridFormatFinder.findFormat("H:\\trans32635.png");<o:p></o:p></p>
<p class="MsoNormal"> <span lang="EN-US">Hints hints=null;;<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> GridCoverage2DReader reader = null;<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> if (!format.getName().equals("Unknown Format"))<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> hints = new Hints();<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> if (format instanceof GeoTiffFormat) {<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> hints = new Hints(Hints.FORCE_LONGITUDE_FIRST_AXIS_ORDER, Boolean.TRUE);<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> }<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> try {<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> reader = format.getReader("H:\\trans32635.png", hints);<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> GridCoverage2D cov = null;<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> cov = reader.read(null); // here it breaks<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> …<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> …<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> } catch (Exception e1) {<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> e1.printStackTrace();<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> }<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> }<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> }<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">The problem is reading "GridCoverage2D" from the reader "cov = reader.read(null);", where it breaks. It works with the original TIF-file.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;font-family:"Segoe UI",sans-serif;color:#242729;background:#F9F8F6">The program breaks here:
<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;font-family:"Segoe UI",sans-serif;color:#242729;background:#F9F8F6">java.awt.geom.affineTransform.class (public AffineTransform(AffineTransform Tx) { this.m00 = Tx.m00; )</span><span lang="EN-US"><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.5pt;font-family:"Segoe UI",sans-serif;color:#242729;background:#F9F8F6">I have the gt-image module and matching .wld, .prj and .png.aux.xml files.</span><span lang="EN-US"><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">I'm running the JAVA-program on Windows 10 and using GDAL 3.21 and org.geotools
</span><span lang="EN-US" style="font-size:10.0pt;font-family:Consolas;color:black;background:#E8F2FE">0.0.1-SNAPSHOT</span><span lang="EN-US">.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">Any ideas?<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">Kind regards,<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">Paul<o:p></o:p></span></p>
</div>
</body>
</html>