[gdal-dev] ECW projection data using Dataset.GetProjectionRef()
kpribadi at rscusa.com
Tue Oct 20 17:41:13 EDT 2009
I set GDAL_DATA environment variable before calling GDAL in my C#
Environment.SetEnvironmentVariable("GDAL_DATA", path + "\\data");
Where path is the FWTools folder location.
Now I can read ECW projection WKT value.
From: Tamas Szekeres [mailto:szekerest at gmail.com]
Sent: Tuesday, October 20, 2009 11:50 AM
To: Kris Pribadi
Cc: gdal-dev at lists.osgeo.org
Subject: Re: [gdal-dev] ECW projection data using
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.
2009/10/20 Kris Pribadi <kpribadi at rscusa.com>
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.
This is the fields definition:
This is my program:
OSGeo.GDAL.Gdal.AllRegister(); //Register drivers.
_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
//TODO May fail if wrong file type?
//TODO projectionWKT may be null if no info from the
//THIS RETURNS NULL FOR "ECW" FILES
_projectionWKT = _ds.GetProjectionRef();
Console.WriteLine("Projection WKT: " + _projectionWKT);
//Get Spatial Information
_projectionInfo = new
bool _IsGeopgraphic = _projectionInfo.IsGeographic;
bool _IsProjected = _projectionInfo.IsProjected;
_srs = _projectionInfo.SpatialReference;
gdal-dev mailing list
gdal-dev at lists.osgeo.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the gdal-dev