Opened 14 years ago

Closed 14 years ago

Last modified 14 years ago

#3092 closed bug (fixed)

Gdal Tools Merge tool fails to read extents

Reported by: sowelu Owned by: brushtyler
Priority: major: does not work as expected Milestone: Version 1.6.0
Component: Python plugins and bindings Version: Trunk
Keywords: Cc:
Must Fix for Release: No Platform: Debian
Platform Version: Kubuntu 10.04 Awaiting user input: no

Description

Using GDAL Tools, Warp tool I was getting a Python message that an index was out of range. The problem was in this code in doMerge.py where indicated

    info = QString( arr ).split( "\n" )
    ulCoord = info[ info.indexOf( QRegExp( "^Upper\sLeft.*" ) ) ].simplified()
    lrCoord = info[ info.indexOf( QRegExp( "^Lower\sRight.*" ) ) ].simplified()
    ul = ulCoord.split( " " )
    lr = lrCoord.split( " " )
    xUL = ul[ 3 ].replace( ",", "" ).toDouble() [ 0 ]  <--- Index error
    yUL = ul[ 4 ].replace( ")", "" ).toDouble()[ 0 ]
    xLR = lr[ 3 ].replace( ",", "" ).toDouble()[ 0 ]
    yLR = lr[ 4 ].replace( ")", "" ).toDouble()[ 0 ]

This resulted from a raster with the following partial gdalinfo

Upper Left  (13631210.192,-3336272.678)
Lower Left  (13631210.192,-3348502.603)
Upper Right (13643440.117,-3336272.678)
Lower Right (13643440.117,-3348502.603)
Center      (13637325.154,-3342387.640)

It appears as though the ulCoord string is not being split properly on spaces, because the spaces do not exist around the comma and bracket. I am compiling QGIS with GDAL trunk (on Linux), so maybe the format has changed.

The code below fixed the problem and might be more robust (although I am not very good at python).

    info = QString( arr ).split( "\n" )
    ulCoord = info[ info.indexOf( QRegExp( "^Upper\sLeft.*" ) ) ].simplified()
    lrCoord = info[ info.indexOf( QRegExp( "^Lower\sRight.*" ) ) ].simplified()
    xUL = ulCoord[ulCoord.indexOf( "(" ) + 1 : ulCoord.indexOf( "," ) - 1].toDouble()[0]
    yUL = ulCoord[ulCoord.indexOf( "," ) + 1 : ulCoord.indexOf( ")" ) - 1].toDouble()[0]
    xLR = lrCoord[lrCoord.indexOf( "(" ) + 1 : lrCoord.indexOf( "," ) - 1].toDouble()[0]
    yLR = lrCoord[lrCoord.indexOf( "," ) + 1 : lrCoord.indexOf( ")" ) - 1].toDouble()[0]

Roland

Change History (3)

comment:1 by borysiasty, 14 years ago

Owner: changed from borysiasty to brushtyler

in reply to:  description comment:2 by brushtyler, 14 years ago

Resolution: fixed
Status: newclosed

Replying to sowelu:

Using GDAL Tools, Warp tool I was getting a Python message that an index was out of range.

Did you mean Merge tool, isn't it?

Fixed from r14513

comment:3 by brushtyler, 14 years ago

Summary: Gdal Tools Warp tool fails to read extentsGdal Tools Merge tool fails to read extents
Note: See TracTickets for help on using tickets.