[gdal-dev] How to extract Well Known Text Coordinate System information (WKT)..., OGR unresolved reference problem

Frank Warmerdam warmerdam at pobox.com
Thu Apr 22 12:29:05 EDT 2010

Zermeno, Robert J CIV NAVAIR, 472100D wrote:
> Hi everyone,
> I am enjoying the simplicity of GDAL with integrating with various formats.
> I have two related questions. 1.  How can I simply extract individual pieces
> of WKT?  Meaning, The returned string from GetProjectionRef() returns a WKT
> format coordinate system string describing the geographical reference the
> image pertains to.  I would like to grab each of the components.


The GetAttrValue() method on OGRSpatialReference can generally be used
to extract specific data items from a coordinate system definition.
For instance:

   const char *pszDatumName = poSRS->GetAttrValue("DATUM");

would search the WKT for the DATUM node, and extract the
associated text.

> 2. This is kind of a question: Instead of parsing through the XML myself, I
> thought GDAL already has this functionality.  I have tried to perform:
> OGRSpatialReferenceH poSRS; poSRS->GetPrimeMeridian(), but I receive an
> unresolved reference compile error.  This is odd to me.  I can do the GDAL
> API tutorial section that uses OSRSetUTM(), OSRDestroySpatialReference(),
> OSRExportToWKt(). I have tried to include all main ogr.h files: ogr_api.h,
> ogr_spatialref.h, ogr_core.h, ... But no such luck.
> The platform I am using is Borland C++.  I compiled a dll and lib file
> through MSVC 2008 and used Borland coff2omf.exe to properly convert the lib
> file.

My conclusion would be that this is something peculiar about the
way you are building or Borland C++.  It may help to stick to the
C rather than C++ API though there are some methods not exposed
through C.

Good luck,
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
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