[QGIS-trac] Re: [Quantum GIS] #1540: "Save as Image" georeference is off up to 1 cell

Quantum GIS qgis at qgis.org
Wed Apr 8 23:00:56 EDT 2009


#1540: "Save as Image" georeference is off up to 1 cell
--------------------------------------------------------------+-------------
        Reporter:  msieczka                                   |         Owner:  nobody       
            Type:  bug                                        |        Status:  new          
        Priority:  critical: causes crash or data corruption  |     Milestone:  Version 1.0.2
       Component:  Rasters                                    |       Version:  HEAD         
      Resolution:                                             |      Keywords:               
Platform_version:                                             |      Platform:  Debian       
        Must_fix:  Yes                                        |   Status_info:  0            
--------------------------------------------------------------+-------------
Comment (by smizuno):

 The offset is caused in part by two things:

 1. the world file may lack sufficient precision for the origin and
 possibly the cell dimensions[[BR]]
 2. the origin written to the world file is the corner of the top left
 cell, where it should be the '''center''' of the top left cell

 I have also found additional problems

 1. on Windows the line terminations of the world file have 2 carriage
 returns and a line feed which causes gdal to not use the file, therefore
 not positioning the image in the expected place.[[BR]]
 2. dotted file names are possible for the image, but the world file would
 just get the base name without the additional parts up to the extension.

 I provide a patch to QgsMapCanvas::saveAsImage() which fixes these
 problems:

 1. the numbers (except the hard-coded rotations) are written to the world
 file with up to 17 digits precision using the "g", 17 formatting
 options.[[BR]]
 2. the center of the top left cell is written for the origin.[[BR]]
 3. Text mode is not used in the file open call, allowing the explicit
 "\r\n" without any translation. The carriage return really isn't
 necessary, but helps when viewing the file on Windows.[[BR]]
 4. use completeBaseName function to obtain the base file name for the
 world file.

-- 
Ticket URL: <https://trac.osgeo.org/qgis/ticket/1540#comment:1>
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