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

Henneke, Amanda M amanda.m.henneke at boeing.com
Tue Oct 20 14:21:29 EDT 2009


Hi Kris-

You wouldn't by any chance have opened these geotiffs in ERDAS Imagine have you?  Are there .aux or .rrd files associated with these images?

Thanks,
Amanda

Amanda M. Henneke

When One tugs at a single thing in Nature, he finds it attached to the rest of the world. -John Muir

  Please consider the environment before printing this e-mail.



________________________________
From: gdal-dev-bounces at lists.osgeo.org [mailto:gdal-dev-bounces at lists.osgeo.org] On Behalf Of Kris Pribadi
Sent: Tuesday, October 20, 2009 1:19 PM
To: gdal-dev at lists.osgeo.org
Subject: [gdal-dev] ECW projection data using Dataset.GetProjectionRef()

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/9c018fde/attachment-0001.html


More information about the gdal-dev mailing list