Global Mapper v25.0

Change projection on tiff and export it with changed projection as raster data

dana5dana Global Mapper UserTrusted User
edited June 2012 in SDK

How can I change the projection in a tiff layer and then export it as raster layer with changed projection?

I have a tiff file and I load it with GM_LoadLayerListEx. I then extract the layer from the layerList and the layerInfo.

What I want to do is to change the projection of the layer and then export it to an image format with the changed projection. For changing the projection, I have a file tiffProjName that is loaded (.prj file)

GM_Projection_t loadedProj;
theError = GM_LoadProjectionFile(tiffProjName, &loadedProj);
theError = GM_SetProjection(&loadedProj);

The projection is now the one I want (loadedProj)and I want to export it with the new projection as an image.

theError=GM_ExportRaster(“d:\\newProjFile.png”, GM_Export_GeoTIFF,_theTiffLayer,&_tiffLayerInfo->mGlobalRect, _tiffLayerInfo->mPixelWidth,_tiffLayerInfo->mPixelHeight,GM_ExportFlags_JPGinTIFF);

Here I have the error code 8 no data to export.

Can u please tell me what is wrong?

If this is not a solution, is there a solution to change the tiff layer projection and then export it as an image with the new projection?

Thank you,


  • global_mapper
    global_mapper Administrator
    edited June 2012

    That looks correct, but when did you get the _tiffLayerInfo structure? If you got that before calling GM_SetProjection the mGlobalRect will still be of the old projection. You need to call GM_GetLayerInfo after calling GM_SetPRojection so that the global bounds will be updated to the new projection.

    Let me know if I can be of further assistance.


    Global Mapper Guru