[Gdal-dev] Re: OGR Spatial Questions

Frank Warmerdam fwarmerdam at gmail.com
Tue Jan 18 08:41:12 EST 2005


On Mon, 17 Jan 2005 22:47:37 -0800, pvg <pvg at pixelmapper.com> wrote:
> Hi Frank,
> 
> I've been having some trouble trying to post to the gdal news group so
> I'm sending this email directly to you. Maybe it will post this time??

Peter,

remotesensing.org (where the gdal-dev mailing list is hosted) was
down for a couple days.  Things should be working now. 
 
> Works fine. Then I load a geotiff and try the following:
> 
>     char *pszProjection = GTIFGetOGISDefn(gtif, &defn );
>     // string looks like it should
> 
>     OGRSpatialReference oSRS;
>     OGRErr i = oSRS.SetProjection( pszProjection );

Here lies your problem.  The SetProjection() method is used to
set the projection method to be used, such as "Transverse_Mercator".
To import a complete WKT coordinate system definition you should
use the importFromWkt() method.  

eg. 

char *pszProjectionCopy = pszProjection;
OGRSpatialReference oSRS;

if( oSRS.importFromWkt( &pszProjectionCopy ) != OGRERR_NONE )
  return;

The setting up of a duplicate pointer to the WKT definition
is because importFromWkt() updates to pointer to point to the
next character past the imported definition.  The approach was
intended to let me process WKT out of a larger string, but in 
practice I have never used that ability and the method has been
clumsy to use (as above). 

Best regards,

-- 
---------------------------------------+--------------------------------------
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