I've installed Mapserver and used a map file to set a raster layer and vector(shp) layers on top of it. However, although displayed in the expected order, the png file is displayed in mirror(compared to it while being built in OpenEV): alt text

alt text any ideas on what is the cause of this and a possible remedy are welcomed. Thanks!

from the .map file, the raster layer:

    NAME "level_2"
    DATA "lv2.png"

gdalinfo on the .png file

Driver: PNG/Portable Network Graphics
Files: /var/www/mapsdemo/e/data/lv2.png
Size is 1591, 967
Coordinate System is `'
Image Structure Metadata:
Corner Coordinates:
Upper Left  (    0.0,    0.0)
Lower Left  (    0.0,  967.0)
Upper Right ( 1591.0,    0.0)
Lower Right ( 1591.0,  967.0)
Center      (  795.5,  483.5)
Band 1 Block=1591x1 Type=Byte, ColorInterp=Red
Band 2 Block=1591x1 Type=Byte, ColorInterp=Green
Band 3 Block=1591x1 Type=Byte, ColorInterp=Blue
  • A little more info is likely needed to diagnose this. Can you post your mapfile layer text? Also, since you have OpenEV installed (and I assume the GDAL tools) , can you run gdalinfo on the raster dataset and post the output?
    – DavidF
    Jan 3, 2011 at 19:07
  • This kind of error is typically due to (a) reversal of row ordering (low-to-high vs. high-to-low) or (b) transposition of columns and rows. Both would have to occur to produce this vertical mirroring.
    – whuber
    Jan 3, 2011 at 20:59
  • still haven't figured out what causes this. any clues? Jan 6, 2011 at 11:14
  • 1
    Can you post the worldfile of the png ? (.pgw file) Jan 28, 2011 at 9:36

2 Answers 2


Adjusting or adding a world file solves this easily.

The positive or negative direction of the first and fourth lines of a world file determine how the image reflects over an axis. To reflect an image over the x axis, flip the direction of the first line. To reflect an image over the y axis, flip the direction of the fourth line.

I think in your case the world file would simply be something like:


If that produces the wrong reflection, then just flip the sign of the first or fourth line as needed.


You need to set the coordinate reference system, currently the Y-value is increasing in the wrong direction (unless you live in the southern hemisphere).

  • 1
    More often than not, image rows are numbered from top to bottom (as is done here) rather than bottom to top. Normally the row and column indexes are not coordinates in a CRS (notice the empty coordinate system identifier): it takes a world file, or the equivalent, to relate them to a CRS.
    – whuber
    Jul 2, 2012 at 20:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.