[Gdal-dev] (no subject)

Bill Bob saddergoat at hotmail.com
Mon May 26 15:26:45 EDT 2003


Hi,

I am trying to get familiar with the API by following the WarpAPI tutorial 
and also from gdalwarp.c and gdalwarptest.c.

I have included some of my code.  It appears that I do not setup the correct 
transformation.  My resulting image is in the orginal projection.

Any thoughts?


    char *pszTmpSrc = NULL;
    char *pszTmpDst = NULL;
    char *pszTargetSRS = NULL;
    char *pszSourceSRS = NULL;
    unsigned char aByte;
    int i,verbose=0;
    FILE *fpBuff = NULL;

    //GDAL specific vars
	GDALDatasetH hSrsDataset=NULL,hDstDataset=NULL;
	GDALWarpOptions *psWarpOptions=NULL;
	GDALWarpOperation oOperation;
    double adfGeoTransform[6];


// ....

	psWarpOptions = GDALCreateWarpOptions();
	psWarpOptions->hSrcDS = hSrsDataset;
	psWarpOptions->hDstDS = hDstDataset;
	psWarpOptions->nBandCount = GDALGetRasterCount(hSrsDataset); //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;


	// set projection transformer
	psWarpOptions->pTransformerArg = GDALCreateGenImgProjTransformer( 
hSrsDataset,
	                                                                  
GDALGetProjectionRef(hSrsDataset),
	                                                                  
hDstDataset,
	                                                                  
GDALGetProjectionRef(hDstDataset),
	                                                                  FALSE,
	                                                                  0.0,
	                                                                  1
	                                                                );

	psWarpOptions->pfnTransformer = GDALGenImgProjTransform;

	// do the warp
	if( oOperation.Initialize( psWarpOptions ) == CE_None )
	{
		oOperation.ChunkAndWarpImage( 0, 0,GDALGetRasterXSize( hDstDataset 
),GDALGetRasterYSize( hDstDataset ));
	}

	// clean up after the reprojection
	GDALDestroyGenImgProjTransformer( psWarpOptions->pTransformerArg );
	GDALDestroyWarpOptions( psWarpOptions );
	GDALClose( hSrsDataset );
	GDALClose( hDstDataset );

_________________________________________________________________
Add photos to your messages with MSN 8. Get 2 months FREE*.  
http://join.msn.com/?page=features/featuredemail




More information about the Gdal-dev mailing list