[gdal-dev] ECW projection data using Dataset.GetProjectionRef()
Kris Pribadi
kpribadi at rscusa.com
Tue Oct 20 17:41:13 EDT 2009
Tamas:
This works!
I set GDAL_DATA environment variable before calling GDAL in my C#
program using:
Environment.SetEnvironmentVariable("GDAL_DATA", path + "\\data");
Where path is the FWTools folder location.
Now I can read ECW projection WKT value.
Thanks.
Kris
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
Dataset.GetProjectionRef()
Kris,
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.
Best regards,
Tamas
2009/10/20 Kris Pribadi <kpribadi at rscusa.com>
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;
_______________________________________________
gdal-dev mailing list
gdal-dev at lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/gdal-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/gdal-dev/attachments/20091020/c44ca377/attachment-0001.html
More information about the gdal-dev
mailing list