#1540 closed bug (fixed)
"Save as Image" georeference is off up to 1 cell
Reported by: | msieczka | Owned by: | nobody |
---|---|---|---|
Priority: | critical: causes crash or data corruption | Milestone: | |
Component: | Rasters | Version: | Trunk |
Keywords: | Cc: | ||
Must Fix for Release: | Yes | Platform: | Debian |
Platform Version: | Awaiting user input: | no |
Description
Compared to an original raster on QGIS map canvas, the raster map (png+pngw) that "Save as Image" creates is off up to one cell vertically and/or horizontally.
- Load a raster map.
- Zoom in until you see raster map cells.
- "Save as Image".
- Load the saved raster map and compare.
Attachments (1)
Change History (6)
comment:1 by , 15 years ago
follow-up: 3 comment:2 by , 15 years ago
I tried the patch but I still have an offset. What I did was the following (with applied patch):
- load a raster map
- zoom to best resolution
- save as image
- load image as additional raster layer
- toggle new image layer on and off
I still have small shifts in the image. Do you also have this effects or is it only on my system?
Regards, Marco
comment:3 by , 15 years ago
Replying to mhugent:
I don't notice any offsets when I use the procedure you list. This is exactly what I was doing to determine the problem and test my changes. I have also tried at different scales - no difference between map and image.
As long as the extent isn't changed the image saved exactly overlays the original map.
I am using rasters in UTM zone 15, NAD83.
I have considered what would happen with other CRS and believe that there shouldn't be any problem. I did test with a raster in a local county coordinate system in the same general area and found that the saved image exactly overlays the map as expected.
Here are some Python statements I used to get the values for the world file, which I modified by hand at first. These were just executed in the Python console. The results should be the same as written to the world file for the saved image.
Cell size: iface.mapCanvas().mapUnitsPerPixel()
Coordinates of center of Upper Left cell: iface.mapCanvas().extent().xMinimum()+(iface.mapCanvas().mapUnitsPerPixel()/2),iface.mapCanvas().extent().yMaximum()-(iface.mapCanvas().mapUnitsPerPixel()/2)
I am interested in any further information as I do want to get this correct.
Regards, Steve
comment:4 by , 15 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
After looking at it again I think that you are right. The small image differences that I noticed are probably due to image compression and not because of image position. The patch is applied to trunk now (r10592).
The offset is caused in part by two things:
I have also found additional problems
I provide a patch to QgsMapCanvas::saveAsImage() which fixes these problems: