<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="Generator" CONTENT="MS Exchange Server version 6.5.7638.1">
<TITLE>I need some help on using the SetMercator method</TITLE>
</HEAD>
<BODY>
<!-- Converted from text/plain format -->

<P><FONT SIZE=2>I'm having some problems with the SetMercator method of OGRSpatialReference when using the GDAL Warp API. I'm writing an app the reads GeoTiff files and warps them into a memory raster. Things are ok without setting the target raster to be projected i.e.&nbsp;<BR>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; oSRS.SetWellKnownGeogCS( &quot;WGS84&quot; );<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; oSRS.exportToWkt( &amp;pszSRS_WKT );<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; poDstDS-&gt;SetGeoTransform( adfGeoTransform );<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; poDstDS-&gt;SetProjection( pszSRS_WKT );<BR>
<BR>
Source data is transferred to target raster correctly by the warp operation.<BR>
<BR>
Note: I have previously calculated the GeoTransform array as follows:<BR>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; adfGeoTransform[0] = tl_lon;<BR>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (br_lon &gt; tl_lon)<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; adfGeoTransform[1] = (br_lon - tl_lon) / iwidth;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; adfGeoTransform[1] = (br_lon + 360.0 - tl_lon) / iwidth;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; adfGeoTransform[2] = 0;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; adfGeoTransform[3] = tl_lat;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; adfGeoTransform[4] = 0;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; adfGeoTransform[5] = ((br_lat - tl_lat) / iheight);<BR>
<BR>
Where tl_lat, tl_lon, br_lat, br_lon are the geographic extents of my target raster and iwidth and iheight are the raster sizes.<BR>
<BR>
As soon as I set the target raster to be projected i.e.<BR>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; oSRS.SetProjCS(&quot;Mercator Projection&quot;);<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; oSRS.SetWellKnownGeogCS( &quot;WGS84&quot; );<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; oSRS.SetMercator (0, 0, 1.0, 0, 0);<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; oSRS.exportToWkt( &amp;pszSRS_WKT );<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; poDstDS-&gt;SetGeoTransform( adfGeoTransform );<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; poDstDS-&gt;SetProjection( pszSRS_WKT );<BR>
<BR>
Now the target raster is not filled (all black). I've experimented a little with the parameters to the SetMercator method. Setting the scale factor to 0 caused one of my tiff files (large map of europe) to warp ok, however, a small map ~300km wide in Afghanistan didn't warp (all black in the target again).<BR>
<BR>
Can anyone advise on what the parameters passed to SetMercator should be? Also, what does scale factor mean in this context? Is there anything else I should be doing?<BR>
<BR>
Many thanks for any help anyone can give.<BR>
<BR>
Best regards,<BR>
<BR>
John Rawlinson</FONT>
</P>

</BODY>
</HTML>