<!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>RE: [Gdal-dev] I need some help on using the SetMercator method</TITLE>
</HEAD>
<BODY>
<!-- Converted from text/plain format -->
<P><FONT SIZE=2>I've got some more info on the problem I'm seeing.<BR>
<BR>
It seems like I only see the problem for source files that are projected. The WKT for the Afghanistan file is as follows:<BR>
PROJCS["unnamed",GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.2572235630016,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0],UNIT["degree",0.0174532925199433],AUTHORITY["EPSG","4326"]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",0],PARAMETER["central_meridian",69],PARAMETER["scale_factor",0.9996],PARAMETER["false_easting",500000],PARAMETER["false_northing",0],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AUTHORITY["EPSG","32642"]]<BR>
<BR>
If I first warp this file to a non-projected tif file, I can then read that tif file and warp it to a Mercator projected output image ok.<BR>
<BR>
Although I could do this as a two stage process it seems tortuous and won't be good for performance - is this expected behaviour or am I missing something?<BR>
<BR>
Thanks,<BR>
<BR>
John<BR>
-----Original Message-----<BR>
From: gdal-dev-bounces@lists.maptools.org on behalf of Rawlinson, John (UK)<BR>
Sent: Thu 29/12/2005 17:51<BR>
To: gdal-dev@lists.maptools.org<BR>
Subject: [Gdal-dev] I need some help on using the SetMercator method<BR>
<BR>
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.<BR>
<BR>
oSRS.SetWellKnownGeogCS( "WGS84" );<BR>
oSRS.exportToWkt( &pszSRS_WKT );<BR>
poDstDS->SetGeoTransform( adfGeoTransform );<BR>
poDstDS->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>
adfGeoTransform[0] = tl_lon;<BR>
<BR>
if (br_lon > tl_lon)<BR>
{<BR>
adfGeoTransform[1] = (br_lon - tl_lon) / iwidth;<BR>
}<BR>
else<BR>
{<BR>
adfGeoTransform[1] = (br_lon + 360.0 - tl_lon) / iwidth;<BR>
}<BR>
adfGeoTransform[2] = 0;<BR>
<BR>
adfGeoTransform[3] = tl_lat;<BR>
adfGeoTransform[4] = 0;<BR>
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>
oSRS.SetProjCS("Mercator Projection");<BR>
oSRS.SetWellKnownGeogCS( "WGS84" );<BR>
oSRS.SetMercator (0, 0, 1.0, 0, 0);<BR>
oSRS.exportToWkt( &pszSRS_WKT );<BR>
poDstDS->SetGeoTransform( adfGeoTransform );<BR>
poDstDS->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<BR>
<BR>
<BR>
<BR>
</FONT>
</P>
</BODY>
</HTML>