Kris,<br><br>I guess you should make some of the GDAL support files (like ecw_cs.wkt) available to load by the driver. You should either set up the GDAL_DATA environment variable to point to the location of the file, or just copy the file into your directory from where the executable is running.<br>
<br><br>Best regards,<br><br>Tamas<br><br><br><div class="gmail_quote">2009/10/20 Kris Pribadi <span dir="ltr">&lt;<a href="mailto:kpribadi@rscusa.com">kpribadi@rscusa.com</a>&gt;</span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">









<div link="blue" vlink="purple" lang="EN-US">

<div>

<p class="MsoNormal">Hi:</p>

<p class="MsoNormal"><span style="color: rgb(31, 73, 125);"> </span></p>

<p class="MsoNormal"><span style="color: rgb(31, 73, 125);">I am a new GDAL user using C#.</span></p>

<p class="MsoNormal"><span style="color: rgb(31, 73, 125);"> </span></p>

<p class="MsoNormal">I am using C# implementation of GDAL from FW_Tools. I am
trying to write a <span style="color: rgb(31, 73, 125);">C</span># program similar to
gdalinfo to extract the metadata from raster files. It is working fine with
GeoTiff files, but having problem reading ECW metadata file. The spatial
projection  “<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">_projectionWKT”</span>
info returns “null”. However, when I use gdalinfo, it prints out
the ECW file coordinate system as WGS_84, which is correct. Does gdalinfo
assume “WGS_84” if GetProjectionRef() is null? How does it get the
projection info from ECW file? </p>

<p class="MsoNormal"> </p>

<p class="MsoNormal">I appreciate any help or suggestion<span style="color: rgb(31, 73, 125);">s</span>.</p>

<p class="MsoNormal"> </p>

<p class="MsoNormal">Thanks</p>

<p class="MsoNormal">Kris</p>

<p class="MsoNormal"> </p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">This is the fields definition:</span></p>

<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">  OSGeo.GDAL.<span style="color: rgb(43, 145, 175);">Dataset</span> _ds;</span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">        <span style="color: rgb(43, 145, 175);">SpatialReference</span> _srs;</span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">        <span style="color: rgb(43, 145, 175);">SpatialProjectionInfo</span> _projectionInfo;</span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"> </span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"> </span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">This is my program:</span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"> </span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">               
OSGeo.GDAL.<span style="color: rgb(43, 145, 175);">Gdal</span>.AllRegister(); <span style="color: green;">//Register drivers.</span></span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">               
OSGeo.OGR.<span style="color: rgb(43, 145, 175);">Ogr</span>.RegisterAll();</span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"> </span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">               
_ds = OSGeo.GDAL.<span style="color: rgb(43, 145, 175);">Gdal</span>.Open(Filename,
OSGeo.GDAL.<span style="color: rgb(43, 145, 175);">Access</span>.GA_ReadOnly); <span style="color: green;">//Open dataset from files</span></span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: green;"> </span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: green;"> </span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">               
<span style="color: blue;">if</span> (_ds == <span style="color: blue;">null</span>)</span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">               
{</span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">                   
<span style="color: blue;">throw</span> <span style="color: blue;">new</span> <span style="color: rgb(43, 145, 175);">Exception</span>(<span style="color: rgb(163, 21, 21);">&quot;The
files could not be loaded&quot;</span>);</span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">               
}</span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"> </span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">               
<span style="color: green;">//TODO May fail if wrong file type?</span></span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">               
_ds.GetGeoTransform(_dbGeoTrans);</span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"> </span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">               
<span style="color: green;">//TODO projectionWKT may be null if no info from the
file.</span></span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: green;">           
    //THIS RETURNS NULL FOR “ECW” FILES</span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">               
_projectionWKT = _ds.GetProjectionRef();</span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"> </span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">               
<span style="color: rgb(43, 145, 175);">Console</span>.WriteLine(<span style="color: rgb(163, 21, 21);">&quot;Projection
WKT: &quot;</span> + _projectionWKT);</span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"> </span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">               
<span style="color: green;">//Get Spatial Information  </span></span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">               
_projectionInfo = <span style="color: blue;">new</span> <span style="color: rgb(43, 145, 175);">SpatialProjectionInfo</span>(projectionWKT);
</span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">               
<span style="color: rgb(31, 73, 125);">bool </span>_IsGeopgraphic =
_projectionInfo.IsGeographic;</span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">               
<span style="color: rgb(31, 73, 125);">bool </span>_IsProjected =
_projectionInfo.IsProjected;</span></p>

<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">               
_srs = _projectionInfo.SpatialReference;</span></p>

<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"> </span></p>

<p class="MsoNormal"> </p>

</div>

</div>


<br>_______________________________________________<br>
gdal-dev mailing list<br>
<a href="mailto:gdal-dev@lists.osgeo.org">gdal-dev@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/gdal-dev" target="_blank">http://lists.osgeo.org/mailman/listinfo/gdal-dev</a><br></blockquote></div><br>