[gdal-dev] Creating geotiff with rotation, but image is flipped

budgie26 sarah.lawrie at ga.gov.au
Tue Feb 16 21:38:34 PST 2016


Hi,

I've been trying to convert a *.png file to geotiff and I have the necessary
coordinates to do so. However I'm having problems trying to get the geotiff
to display properly (it's flipped) and I need some advice! 

The *.png details are:
UL: 37.686398 23.744484
LL: 38.073174 21.922295
UR: 40.149170 24.165144
LR: 40.501301 22.346598
CEN: 39.0938495 23.0437195
Skew/rotation: -12.3321408987529 (anti-clockwise from North)

After extensive searching on the web for solutions, this is how far I've
got:

Start by converting *.png to *.tif using ImageMagick: 

Get information on the *.tif with gdal: 
Driver: GTiff/GeoTIFF
Files: image.tif
Size is 1488, 2447
Coordinate System is `'
Metadata:
  TIFFTAG_DOCUMENTNAME=image.tif
  TIFFTAG_RESOLUTIONUNIT=1 (unitless)
  TIFFTAG_XRESOLUTION=72
  TIFFTAG_YRESOLUTION=72
Image Structure Metadata:
  COMPRESSION=DEFLATE
  INTERLEAVE=PIXEL
Corner Coordinates:
Upper Left  (    0.0,    0.0)
Lower Left  (    0.0, 2447.0)
Upper Right ( 1488.0,    0.0)
Lower Right ( 1488.0, 2447.0)
Center      (  744.0, 1223.5)
Band 1 Block=1488x1 Type=Byte, ColorInterp=Red
Band 2 Block=1488x1 Type=Byte, ColorInterp=Green
Band 3 Block=1488x1 Type=Byte, ColorInterp=Blue

Convert the *.tif to a geotif by using GCPs:


Apply the projection, WGS84:


The resulting image is:

<http://osgeo-org.1560.x6.nabble.com/file/n5251005/image_init_geo.png> 

The image is in the correct orientation and coordinate location, but the
image is upside down.

I found a python script (
http://blog.perrygeo.net/2007/09/05/the-world-turned-right-side-up/
<http://blog.perrygeo.net/2007/09/05/the-world-turned-right-side-up/>  )
that will flip the image to the correct view, but the orientation is now
wrong:

<http://osgeo-org.1560.x6.nabble.com/file/n5251005/image_geo.png> 

I’m new to python so I haven’t been able to work out if there is something
in the python script that can be changed to resolve this problem. 

Initially I tried to manually create a world file (
https://en.wikipedia.org/wiki/World_file
<https://en.wikipedia.org/wiki/World_file>  ), but I just couldn’t get it to
plot in the correct location, even with the rotation values set to zero:


*.tfw contents:
0.001891736
0.0000000000
0.0000000000
-0.000916571
37.68734387
23.74494229

metadata.txt contents:
Geotiff_Information:
   Version: 1
   Key_Revision: 1.0
   Tagged_Information:
      ModelTiepointTag (2,3):
         0                0                0
        37.686398  23.744484     0
      ModelPixelScaleTag (1,3):
         0.001891736       -0.000916571      0
      End_Of_Tags.
   Keyed_Information:
      GTModelTypeGeoKey (Short,1): ModelTypeGeographic
      GTRasterTypeGeoKey (Short,1): RasterPixelIsArea
      GeographicTypeGeoKey (Short,1): GCS_WGS_84
      End_Of_Keys.
   End_Of_Geotiff.

GCS: 4326/WGS 84
Datum: 6326/World Geodetic System 1984
Ellipsoid: 7030/WGS 84 (6378137.00,6356752.31)
Prime Meridian: 8901/Greenwich (0.000000/  0d 0' 0.00"E)

PROJ.4 Definition: +proj=latlong +ellps=WGS84 +to_meter=1.0000000000

Corner Coordinates:
Upper Left    (37.686398, 23.744484)
Lower Left    (38.073174, 21.922295)
Upper Right   (40.14917, 24.165144)
Lower Right   (40.501301, 22.346598)
Center        (39.0938495, 23.0437195)


Does anyone have any ideas on how I can keep the image’s orientation correct
while flipping it? 




--
View this message in context: http://osgeo-org.1560.x6.nabble.com/Creating-geotiff-with-rotation-but-image-is-flipped-tp5251005.html
Sent from the GDAL - Dev mailing list archive at Nabble.com.


More information about the gdal-dev mailing list