[Gdal-dev] I need some help on using the SetMercator method

Rawlinson, John (UK) JRAWLINSON at ngms.eu.com
Sun Jan 1 08:41:12 EST 2006


I've got some more info on the problem I'm seeing. 

It seems like I only see the problem for source files that are projected. The WKT for the Afghanistan file is as follows:
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"]]

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.

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?

Thanks,

John
-----Original Message-----
From: gdal-dev-bounces at lists.maptools.org on behalf of Rawlinson, John (UK)
Sent: Thu 29/12/2005 17:51
To: gdal-dev at lists.maptools.org
Subject: [Gdal-dev] I need some help on using the SetMercator method
 
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. 

        oSRS.SetWellKnownGeogCS( "WGS84" );
        oSRS.exportToWkt( &pszSRS_WKT );
        poDstDS->SetGeoTransform( adfGeoTransform );
        poDstDS->SetProjection( pszSRS_WKT );

Source data is transferred to target raster correctly by the warp operation.

Note: I have previously calculated the GeoTransform array as follows:

        adfGeoTransform[0] = tl_lon;

        if (br_lon > tl_lon)
        {
                adfGeoTransform[1] = (br_lon - tl_lon) / iwidth;
        }
        else
        {
                adfGeoTransform[1] = (br_lon + 360.0 - tl_lon) / iwidth;
        }
        adfGeoTransform[2] = 0;
       
        adfGeoTransform[3] = tl_lat;
        adfGeoTransform[4] = 0;
        adfGeoTransform[5] = ((br_lat - tl_lat) / iheight);

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.

As soon as I set the target raster to be projected i.e.

        oSRS.SetProjCS("Mercator Projection");
        oSRS.SetWellKnownGeogCS( "WGS84" );
        oSRS.SetMercator (0, 0, 1.0, 0, 0);
        oSRS.exportToWkt( &pszSRS_WKT );
        poDstDS->SetGeoTransform( adfGeoTransform );
        poDstDS->SetProjection( pszSRS_WKT );

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).

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?

Many thanks for any help anyone can give.

Best regards,

John Rawlinson 



-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/gdal-dev/attachments/20060101/a7096484/attachment.html


More information about the Gdal-dev mailing list