[gdal-dev] Projection description class

Frank Warmerdam warmerdam at p...
Mon Jul 9 09:10:36 EDT 2001


Ben Discoe wrote:
> 
> My code, which i'm trying to migrate to leverage GDAL/OGR/etc., used to
> represent geographic projections with a very naive class like this:
> 
> class MyProjection {
> [a bunch of methods]
> bool m_bUTM;
> int m_iUTMZone;
> enum DATUM m_Datum;
> };
> 
> This was fine for most of the USGS products, but is otherwise really
> limited - it doesn't handle State Planes, Albers, and other terribly common
> projections.
> 
> So, i'd like to replace the usage of my Projection class with the
> appropriate class in the GDAL system. Studying the docs, it seems the a
> likely candidate is "GDALProjDef", which in turn is built on
> "OGRSpatialReference" and its related classes.

Ben,

GDALProjDef is a dead-end. I would encourage you to use OGRSpatialReference
directly, as it is intended to superceed the GDALProjDef. 

> Looking at the python source to OpenEV, i find the following:
> 
> projection = gdal_ds.GetProjection()
> if len(projection) > 0:
> sr = osr.SpatialReference()
> if sr.ImportFromWkt( projection ) == 0:
> projection = sr.ExportToPrettyWkt( simplify = 1 )
> 
> This seems to indicate that the underlying "SpatialReference" class is the
> full-featured one. (Is there some reason why 'ExportToPrettyWkt' doesn't
> appear in the C++ version of 'OGRSpatialReference'?)

Why do you say that exportToPrettyWkt() doesn't appear in the C+ version?
It is a method on the OGRSpatialReference. 

> All my code needs is to concisely represent any number of projections and
> quickly convert coordinates between them; should i be looking at using
> GDALProjDef, or OGRSpatialReference, or something else?

OGRSpatialReference can be the coordinate system definition, and 
OGRCoordinateTransformation (built on PROJ.4) can do the reprojection. 

Note that OGRSpatialReference and company are not easily separated from
GDAL. Are you prepared to build in an absolute dependence on GDAL in your
application? If so, It think the OGRSpatialReference and company will
serve you well. 

Best regards,

---------------------------------------+--------------------------------------
I set the clouds in motion - turn up | Frank Warmerdam, warmerdam at p...
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush | Geospatial Programmer for Rent




More information about the Gdal-dev mailing list