Bug report #3092

Gdal Tools Merge tool fails to read extents

Added by sowelu - about 14 years ago. Updated about 14 years ago.

Status:Closed
Priority:Low
Assignee:Giuseppe Sucameli
Category:Python plugins
Affected QGIS version: Regression?:No
Operating System:Debian Easy fix?:No
Pull Request or Patch supplied: Resolution:fixed
Crashes QGIS or corrupts data: Copied to github as #:13152

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( "\
" )
    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( "\
" )
    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()r0
    yUL = ulCoord[ulCoord.indexOf( "," ) + 1 : ulCoord.indexOf( ")" ) - 1].toDouble()r0
    xLR = lrCoord[lrCoord.indexOf( "(" ) + 1 : lrCoord.indexOf( "," ) - 1].toDouble()r0
    yLR = lrCoord[lrCoord.indexOf( "," ) + 1 : lrCoord.indexOf( ")" ) - 1].toDouble()r0

Roland

Associated revisions

Revision be29ad96
Added by Giuseppe Sucameli about 14 years ago

split extent on comma in GdalTools Merge tool, to fix #3092

git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@14513 c8812cc2-4d05-0410-92ff-de0c093fc19c

Revision 838b614d
Added by Giuseppe Sucameli about 14 years ago

split extent on comma in GdalTools Merge tool, to fix #3092

git-svn-id: http://svn.osgeo.org/qgis/trunk@14513 c8812cc2-4d05-0410-92ff-de0c093fc19c

History

#1 Updated by Giuseppe Sucameli about 14 years ago

  • Resolution set to fixed
  • Status changed from Open to Closed

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 838b614d (SVN r14514)

Also available in: Atom PDF