Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#5980 closed defect (fixed)

GDALWarp Geolocation Failed

Reported by: liminlu0314 Owned by: warmerdam
Priority: normal Milestone: 1.11.3
Component: Algorithms Version: 1.11.2
Severity: normal Keywords: Gdalwarp, geoloc
Cc:

Description

GDAL will fail when performing Geolocation warp to the data in the attachment. The error occurs in the file "alg\gdaltransformer.cpp", line 703~706, when GDALSuggestedWarpOut2 function is calculating the size of output image.

The original code:

    if( pabSuccess[0] && pabSuccess[nSamplePoints - 1] )
    {
        dfDeltaX = padfX[nSamplePoints-1] - padfX[0];
        dfDeltaY = padfY[nSamplePoints-1] - padfY[0];
    }

when the coordinates of the first point(0) and the last point(nSamplePoints-1) are equal, dfDeltaX and dfDeltaY will both be zero, leading to the calculation error of output image size. This can be solved by the following codes:

    if( pabSuccess[0] && pabSuccess[nSamplePoints - 1] )
    {
        dfDeltaX = padfX[nSamplePoints-1] - padfX[0];
        dfDeltaY = padfY[nSamplePoints-1] - padfY[0];

		if(dfDeltaX == 0 || dfDeltaY == 0)
		{
			dfDeltaX = dfMaxXOut - dfMinXOut;
			dfDeltaY = dfMaxYOut - dfMinYOut;
		}
    }

Accessories for the test data, using gdalwarp tools for testing:

gdalwarp.exe -geoloc H2A_SM2B20130716_09026.vrt H2A_SM2B20130716_09026.tif

H2A_SM2B20130716_09026.h5 is original data;

H2A_SM2B20130716_09026.vrt is virtual data to construct containing Geolocation metadata;

H2A_SM2B20130716_09026.tif is correct warp data.

Change History (4)

comment:1 Changed 6 years ago by liminlu0314

Due to the limited attachment size, the test data have been uploaded to Baidu Cloud, which can be downloaded here:

http://pan.baidu.com/s/1sjyWwY5

Thanks

comment:2 Changed 6 years ago by Even Rouault

Milestone: 1.11.3
Resolution: fixed
Status: newclosed

trunk r29271, branches/1.11 r29272 "Fix failure in GDALSuggestedWarpOut2() when computing output image size in case the top-left and bottom-right corners tranform to the same point (derived from patch by liminlu0314, #5980)"

comment:3 Changed 6 years ago by Even Rouault

trunk r29308, branches/2.0 r29309 (post RC1), branches/1.11 r29310 "GDALSuggestedWarpOut2(): fix typo that could prevent detection of part of the error cases for #5980"

comment:4 Changed 6 years ago by Even Rouault

trunk r29311, branches/2.0 r29312 "Update expected results of test_gdalwarp_41 due to #5980 fix"

Note: See TracTickets for help on using tickets.