<div dir="ltr"><div class="gmail_extra">I have a certain .tif file that I open with GDALOpen() and then call GDALGetProjectionRef(), which returns:</div><div class="gmail_extra"><br></div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div class="gmail_extra">srs = GEOGCS["Merchich",DATUM["Merchich",SPHEROID["Clarke 1880 (IGN)",6378249.2,293.4660212936265,AUTHORITY["EPSG","7011"]],AUTHORITY["EPSG","6261"]],PRIMEM["Greenwich",0],UNIT["degree",0.0174532925199433],AUTHORITY["EPSG","4261"]]</div></blockquote><div class="gmail_extra"><br></div><div class="gmail_extra">I make this into a projection with:</div><div class="gmail_extra"><br></div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div class="gmail_extra">OGRSpatialReference oSRS;<br></div><div class="gmail_extra">oSRS.importFromWkt( &srs );</div><div class="gmail_extra"><div class="gmail_extra">char *sP = NULL;</div></div><div class="gmail_extra"><div class="gmail_extra">oSRS.exportToProj4( &sP );</div></div><div class="gmail_extra"><div class="gmail_extra">sourceProjection = pj_init_plus( sP );</div><div class="gmail_extra">CPLFree( sP );<br></div></div></blockquote><div class="gmail_extra"><div><br></div></div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div class="gmail_extra"><div>(here, sP = "+proj=longlat +a=6378249.2 +b=6356515 +towgs84=31,146,47,0,0,0,0 +no_defs")</div><div><br></div></div></blockquote><div class="gmail_extra">I think make another projection with:</div><div class="gmail_extra"><br></div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div class="gmail_extra">targetProjection = pj_init_plus( "+proj=latlong +datum=WGS84" );</div></blockquote><div class="gmail_extra"><br></div><div class="gmail_extra">I use GDALApplyGeoTransform() to convert the top-left (0, 0) point of the .tif file to geo coordinates, which gives me a lat/lon value of (lon = -7, lat = 34).</div><div class="gmail_extra"><br></div><div class="gmail_extra">pj_is_latlong( sourceProjection ) returns 1, which confirms that this file has a lat/lon projection, and the (-7, 34) seems to be correct (at least in the right area). (The actual numbers from my file are not exact values like this, so I'm rounding here, but it shouldn't matter for the purpose of this discussion.)<br></div><div class="gmail_extra"><br></div><div class="gmail_extra">The problem is that when I call</div><div class="gmail_extra"><br></div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div class="gmail_extra">pj_transform( sourceProjection, targetProjection, 1, 1, &lon, &lat, NULL );</div></blockquote><div class="gmail_extra"><br></div><div class="gmail_extra">it returns both the lon and lat as -infinity (i.e., the double representation of negative infinity).</div><div class="gmail_extra"><br></div><div class="gmail_extra">I don't understand why it's returning invalid values like that. I believe I've used pj_transform() with other lat/lon projections (going from these other lat/lon projections to WGS84 as above) and it's acted basically as a no-op.</div><div class="gmail_extra"><br></div><div class="gmail_extra">However, my concern is that it's not quite a no-op, but may slightly change the lat/lon values to account for differences in the datum and so on. So, I *could* just not do the pj_transform() when pj_is_latlong( sourceProjection ) == 1, but it seems like I *do* want to do transform in general, because of datum differences and so on.</div><div class="gmail_extra"><br></div><div class="gmail_extra">So my question is:</div><div class="gmail_extra"><br></div><div class="gmail_extra">(a) Is it misguided to try to call pj_transform() to go from one lat/lon projection (as in this "Merchich" projection) to a WGS84?</div><div class="gmail_extra"><br></div><div class="gmail_extra">(b) If not, do you know why it seems to be failing? I found this: <a href="http://trac.osgeo.org/osgeo4w/ticket/320">http://trac.osgeo.org/osgeo4w/ticket/320</a>. But I don't believe it's related.</div><div class="gmail_extra"><br></div><div class="gmail_extra">Thanks for any help.</div><div class="gmail_extra"><br></div></div>