[gdal-dev] lib to get from GDAL/geotiff to PROJ4

Etienne Tourigny etourigny.dev at gmail.com
Wed Apr 17 04:48:38 PDT 2013


You can have a look at the code used by the gdalsrsinfo , which basically
opens a GDAL/OGR datasource and outputs the proj4 (or wkt) string.

Assuming you use c/c++ of course...

http://trac.osgeo.org/gdal/browser/trunk/gdal/apps/gdalsrsinfo.cpp

Here is the relevant code (some declarations missing)

poGDALDS = (GDALDataset *) GDALOpen( pszInput, GA_ReadOnly );
    if ( poGDALDS != NULL && poGDALDS->GetProjectionRef( ) != NULL ) {
        pszProjection = (char *) poGDALDS->GetProjectionRef( );
        if( oSRS.importFromWkt( &pszProjection ) == CE_None ) {
            CPLDebug( "gdalsrsinfo", "got SRS from GDAL" );
            bGotSRS = TRUE;
        }
GDALClose( (GDALDatasetH) poGDALDS );
        if ( ! bGotSRS )
            CPLDebug( "gdalsrsinfo", "did not open with GDAL" );
    }

 oSRS.exportToProj4( &pszOutput );
        printf( "\'%s\'\n", pszOutput );


On Wed, Apr 17, 2013 at 8:23 AM, wsvries <wsvries at xs4all.nl> wrote:

> Hi,
> I am working on an application (adding terrain info to maps for 3D
> rendering) that does some heavy projection calculations using the proj4
> libs.
> Input for now is geotiff.
> I have Googled a lot, but I was not able to find any libs that can output
> proj4 strings based on geotiff input.
> I have seen (GDAL based) utilities that are able to do that but no libs to
> use in my application.
> Any hint is welcome.
> Thanks.
> ______________________________**_________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> http://lists.osgeo.org/**mailman/listinfo/gdal-dev<http://lists.osgeo.org/mailman/listinfo/gdal-dev>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20130417/1bb67b92/attachment.html>


More information about the gdal-dev mailing list