0

I would like to translate from TIFF to ASCII,

import os
os.system("gdal_translate -of AAIGrid -a_srs EPSG:25830 " + 'my.tif' + " " +  'my.asc')

But when I do that the ASCII file is moved: ASCII result

Driver: AAIGrid/Arc/Info ASCII Grid
Files: my.asc
       my.asc.aux.xml
       my.prj
Size is 76, 70
Coordinate System is:
PROJCS["ETRS89_UTM_zone_30N",
    GEOGCS["GCS_ETRS_1989",
        DATUM["European_Terrestrial_Reference_System_1989",
            SPHEROID["GRS_1980",6378137,298.257222101]],
        PRIMEM["Greenwich",0],
        UNIT["Degree",0.017453292519943295]],
    PROJECTION["Transverse_Mercator"],
    PARAMETER["latitude_of_origin",0],
    PARAMETER["central_meridian",-3],
    PARAMETER["scale_factor",0.9996],
    PARAMETER["false_easting",500000],
    PARAMETER["false_northing",0],
    UNIT["Meter",1]]
Origin = (493800.000000000000000,4181600.000000000000000)
Pixel Size = (100.000000000000000,-100.000000000000000)
Metadata:
  AREA_OR_POINT=Area
Corner Coordinates:
Upper Left  (  493800.000, 4181600.000) (  3d 4'13.47"W, 37d46'54.22"N)
Lower Left  (  493800.000, 4174600.000) (  3d 4'13.26"W, 37d43' 7.08"N)
Upper Right (  501400.000, 4181600.000) (  2d59' 2.76"W, 37d46'54.29"N)
Lower Right (  501400.000, 4174600.000) (  2d59' 2.81"W, 37d43' 7.16"N)
Center      (  497600.000, 4178100.000) (  3d 1'38.08"W, 37d45' 0.72"N)
Band 1 Block=76x1 Type=Float32, ColorInterp=Gray
  NoData Value=-9999

Original tif file:

Driver: GTiff/GeoTIFF
Files: my.tif
Size is 76, 70
Coordinate System is:
PROJCS["ETRS89 / UTM zone 30N",
    GEOGCS["ETRS89",
        DATUM["European_Terrestrial_Reference_System_1989",
            SPHEROID["GRS 1980",6378137,298.257222101,
                AUTHORITY["EPSG","7019"]],
            TOWGS84[0,0,0,0,0,0,0],
            AUTHORITY["EPSG","6258"]],
        PRIMEM["Greenwich",0,
            AUTHORITY["EPSG","8901"]],
        UNIT["degree",0.0174532925199433,
            AUTHORITY["EPSG","9122"]],
        AUTHORITY["EPSG","4258"]],
    PROJECTION["Transverse_Mercator"],
    PARAMETER["latitude_of_origin",0],
    PARAMETER["central_meridian",-3],
    PARAMETER["scale_factor",0.9996],
    PARAMETER["false_easting",500000],
    PARAMETER["false_northing",0],
    UNIT["metre",1,
        AUTHORITY["EPSG","9001"]],
    AXIS["Easting",EAST],
    AXIS["Northing",NORTH],
    AUTHORITY["EPSG","25830"]]
Origin = (493800.000000000000000,4181600.000000000000000)
Pixel Size = (100.000000000000000,100.000000000000000)
Metadata:
  AREA_OR_POINT=Area
Image Structure Metadata:
  INTERLEAVE=BAND
Corner Coordinates:
Upper Left  (  493800.000, 4181600.000) (  3d 4'13.47"W, 37d46'54.22"N)
Lower Left  (  493800.000, 4188600.000) (  3d 4'13.69"W, 37d50'41.35"N)
Upper Right (  501400.000, 4181600.000) (  2d59' 2.76"W, 37d46'54.29"N)
Lower Right (  501400.000, 4188600.000) (  2d59' 2.72"W, 37d50'41.42"N)
Center      (  497600.000, 4185100.000) (  3d 1'38.16"W, 37d48'47.85"N)
Band 1 Block=76x26 Type=Float32, ColorInterp=Gray
  NoData Value=-9999

In ASCII, the file pixel size 'y' is -100 when should be 100. How can I fix this?

  • 1
    When illustrating the file, is it actually moved, or are you just concerned that a change has occurred? The minus likely has no impact, as the measuring of pixel sizes may have changed from lower left to upper left between the formats, requiring the minus-sign. – Mikkel Lydholm Rasmussen Sep 10 at 10:26
  • The original tiff is South-up that is uncommon but the conversion should not move the image. But if you have created the my.tif image from code I suggest to change the pixel Y into negative value because that's probably what you want: a North-up image with y coordinate decreasing from top to bottom. – user30184 Sep 10 at 21:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.