[QGIS-trac] [Quantum GIS] #3092: Gdal Tools Warp tool fails to read extents

Quantum GIS qgis at qgis.org
Fri Oct 8 03:16:32 EDT 2010


#3092: Gdal Tools Warp tool fails to read extents
------------------------------------------------+---------------------------
   Reporter:  sowelu                            |              Owner:  borysiasty   
       Type:  bug                               |             Status:  new          
   Priority:  major: does not work as expected  |          Milestone:  Version 1.6.0
  Component:  Python plugins and bindings       |            Version:  Trunk        
   Keywords:                                    |   Platform_version:  Kubuntu 10.04
   Platform:  Debian                            |           Must_fix:  No           
Status_info:  0                                 |  
------------------------------------------------+---------------------------
 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

-- 
Ticket URL: <http://trac.osgeo.org/qgis/ticket/3092>
Quantum GIS <http://qgis.org>
Quantum GIS is an Open Source GIS viewer/editor supporting OGR, PostGIS, and GRASS formats


More information about the QGIS-trac mailing list