[gdal-dev] C# Bindings warp image using gcp

Even Rouault even.rouault at mines-paris.org
Wed Aug 10 14:40:14 EDT 2011


Le mercredi 10 août 2011 15:40:33, Edi.Karadumi a écrit :
> Hello im trying to warp an image using 4 or more gcp points. I have already
> done it in c++, but my project is in c# so im trying to convert it. I got
> the following example from the GDAL warp API tutorial and adjusted it for
> my needs. I have done most of the other parts but i cant convert the
> following part
> 
> // Establish reprojection transformer.
> 
>     psWarpOptions->pTransformerArg =
>         GDALCreateGenImgProjTransformer( hSrcDS,
>                                          GDALGetProjectionRef(hSrcDS),
>                                          hDstDS,
>                                          GDALGetProjectionRef(hDstDS),
>                                          TRUE, 0.0, 1 );
>     psWarpOptions->pfnTransformer = GDALGenImgProjTransform;
> 
> I cant find GDALCreateGenImgProjTransformer to create the transformer. How
> can i adapt it i C#?

There's no SWIG bindings for using those low level warp API. The closes match 
I see is the gdal.ReprojectImage() API that will establish a 
GenImgProjTransform and proceed to the warping itself. You can see its C++ 
implementation here :

http://trac.osgeo.org/gdal/browser/trunk/gdal/alg/gdalwarper.cpp

> 
> Best Regards
> Edi Karadumi
> 
> 
> 
> 
> 
> 
> This is the official Example
> 
> #include "gdalwarper.h"
> 
> int main()
> {
>     GDALDatasetH  hSrcDS, hDstDS;
> 
>     // Open input and output files.
> 
>     GDALAllRegister();
> 
>     hSrcDS = GDALOpen( "in.tif", GA_ReadOnly );
>     hDstDS = GDALOpen( "out.tif", GA_Update );
> 
>     // Setup warp options.
> 
>     GDALWarpOptions *psWarpOptions = GDALCreateWarpOptions();
> 
>     psWarpOptions->hSrcDS = hSrcDS;
>     psWarpOptions->hDstDS = hDstDS;
> 
>     psWarpOptions->nBandCount = 1;
>     psWarpOptions->panSrcBands =
>         (int *) CPLMalloc(sizeof(int) * psWarpOptions->nBandCount );
>     psWarpOptions->panSrcBands[0] = 1;
>     psWarpOptions->panDstBands =
>         (int *) CPLMalloc(sizeof(int) * psWarpOptions->nBandCount );
>     psWarpOptions->panDstBands[0] = 1;
> 
>     psWarpOptions->pfnProgress = GDALTermProgress;
> 
>     // Establish reprojection transformer.
> 
>     psWarpOptions->pTransformerArg =
>         GDALCreateGenImgProjTransformer( hSrcDS,
>                                          GDALGetProjectionRef(hSrcDS),
>                                          hDstDS,
>                                          GDALGetProjectionRef(hDstDS),
>                                          FALSE, 0.0, 1 );
>     psWarpOptions->pfnTransformer = GDALGenImgProjTransform;
> 
>     // Initialize and execute the warp operation.
> 
>     GDALWarpOperation oOperation;
> 
>     oOperation.Initialize( psWarpOptions );
>     oOperation.ChunkAndWarpImage( 0, 0,
>                                   GDALGetRasterXSize( hDstDS ),
>                                   GDALGetRasterYSize( hDstDS ) );
> 
>     GDALDestroyGenImgProjTransformer( psWarpOptions->pTransformerArg );
>     GDALDestroyWarpOptions( psWarpOptions );
> 
>     GDALClose( hDstDS );
>     GDALClose( hSrcDS );
> 
>     return 0;
> }
> 
> --
> View this message in context:
> http://osgeo-org.1803224.n2.nabble.com/C-Bindings-warp-image-using-gcp-tp6
> 672396p6672396.html Sent from the GDAL - Dev mailing list archive at
> Nabble.com.
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/gdal-dev


More information about the gdal-dev mailing list