[gdal-dev] ECW projection data using Dataset.GetProjectionRef()

Kris Pribadi kpribadi at rscusa.com
Tue Oct 20 14:18:57 EDT 2009


Hi:

 

I am a new GDAL user using C#.

 

I am using C# implementation of GDAL from FW_Tools. I am trying to write
a C# 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  "_projectionWKT" 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? 

 

I appreciate any help or suggestions.

 

Thanks

Kris

 

This is the fields definition:

  OSGeo.GDAL.Dataset _ds;

        SpatialReference _srs;

        SpatialProjectionInfo _projectionInfo;

 

 

This is my program:

 

                OSGeo.GDAL.Gdal.AllRegister(); //Register drivers.

                OSGeo.OGR.Ogr.RegisterAll();

 

                _ds = OSGeo.GDAL.Gdal.Open(Filename,
OSGeo.GDAL.Access.GA_ReadOnly); //Open dataset from files

 

 

                if (_ds == null)

                {

                    throw new Exception("The files could not be
loaded");

                }

 

                //TODO May fail if wrong file type?

                _ds.GetGeoTransform(_dbGeoTrans);

 

                //TODO projectionWKT may be null if no info from the
file.

                //THIS RETURNS NULL FOR "ECW" FILES

                _projectionWKT = _ds.GetProjectionRef();

 

                Console.WriteLine("Projection WKT: " + _projectionWKT);

 

                //Get Spatial Information  

                _projectionInfo = new
SpatialProjectionInfo(projectionWKT); 

                bool _IsGeopgraphic = _projectionInfo.IsGeographic;

                bool _IsProjected = _projectionInfo.IsProjected;

                _srs = _projectionInfo.SpatialReference;

 

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/gdal-dev/attachments/20091020/382b2398/attachment.html


More information about the gdal-dev mailing list