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.<div><br></div><div>Assuming you use c/c++ of course...</div><div><br></div><div><a href="http://trac.osgeo.org/gdal/browser/trunk/gdal/apps/gdalsrsinfo.cpp">http://trac.osgeo.org/gdal/browser/trunk/gdal/apps/gdalsrsinfo.cpp</a><br>
<br>Here is the relevant code (some declarations missing)</div><div><br></div><div><div>poGDALDS = (GDALDataset *) GDALOpen( pszInput, GA_ReadOnly );</div><div><span class="Apple-tab-span" style="white-space:pre">   </span>    if ( poGDALDS != NULL && poGDALDS->GetProjectionRef( ) != NULL ) {</div>
<div><span class="Apple-tab-span" style="white-space:pre">      </span>        pszProjection = (char *) poGDALDS->GetProjectionRef( );</div><div><span class="Apple-tab-span" style="white-space:pre">   </span>        if( oSRS.importFromWkt( &pszProjection ) == CE_None ) {</div>
<div><span class="Apple-tab-span" style="white-space:pre">      </span>            CPLDebug( "gdalsrsinfo", "got SRS from GDAL" );</div><div><span class="Apple-tab-span" style="white-space:pre">      </span>            bGotSRS = TRUE;</div>
<div><span class="Apple-tab-span" style="white-space:pre">      </span>        }</div><div>GDALClose( (GDALDatasetH) poGDALDS );</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>        if ( ! bGotSRS ) </div>
<div><span class="Apple-tab-span" style="white-space:pre">      </span>            CPLDebug( "gdalsrsinfo", "did not open with GDAL" );</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>    }   </div>
</div><div><div><br></div><div> oSRS.exportToProj4( &pszOutput );</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>        printf( "\'%s\'\n", pszOutput );</div><div><br></div><div>
<br></div><div class="gmail_quote">On Wed, Apr 17, 2013 at 8:23 AM, wsvries <span dir="ltr"><<a href="mailto:wsvries@xs4all.nl" target="_blank">wsvries@xs4all.nl</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi,<br>
I am working on an application (adding terrain info to maps for 3D rendering) that does some heavy projection calculations using the proj4 libs.<br>
Input for now is geotiff.<br>
I have Googled a lot, but I was not able to find any libs that can output proj4 strings based on geotiff input.<br>
I have seen (GDAL based) utilities that are able to do that but no libs to use in my application.<br>
Any hint is welcome.<br>
Thanks.<br>
______________________________<u></u>_________________<br>
gdal-dev mailing list<br>
<a href="mailto:gdal-dev@lists.osgeo.org" target="_blank">gdal-dev@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/gdal-dev" target="_blank">http://lists.osgeo.org/<u></u>mailman/listinfo/gdal-dev</a><br>
</blockquote></div><br></div>