[gdal-dev] Problem when creating GeoTiff raster with null origin and unit spacing

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[gdal-dev] Problem when creating GeoTiff raster with null origin and unit spacing

Cédric Traizet

Hello,

I am trying to create a raster file with the GeoTiff driver, origin [0,0] and pixel size [1,-1]. To do so I used the GDALDriver::Create(...) method with {0,1,0,0,0,-1} as geotransform. But the created output file has no "Pixel Size" or "Origin" metadata fields, and when I run gdalinfo the corner coordinates are flipped along the y axis:

Corner Coordinates:
Upper Left  (    0.0,    0.0)
Lower Left  (    0.0,  512.0)
Upper Right (  512.0,    0.0)
Lower Right (  512.0,  512.0)
Center      (  256.0,  256.0)

instead of the expected:

Upper Left  (    0.0,    0.0)
Lower Left  (    0.0,  -512.0)
Upper Right (  512.0,    0.0)
Lower Right (  512.0,  -512.0)
Center      (  256.0,  -256.0)

If I use another origin, another pixel size or another driver (I tested with the ENVI driver), the output has the "Pixel Size" and "Origin" fields, and the coordinates are not flipped.

Also, if I create the geoTiff file with GDALDriver::CreateCopy(...) on the dataset on which I used Create(...), the output has the correct fields.

Is it a bug ? or am I doing something wrong here ?

Attached is a c++ main that reproduce the problem:

  • It takes as input two filenames, the driver name, the origin and the spacing.
  • It creates a raster using the input driver, the first filename and the method GDALDriver::Create(...).
  • It creates another raster using the second filename. This raster created by copying the first dataset using GDALDriver::CreateDataset(...).
  • config: Ubuntu 16.04, GDAL 2.2.1

    sincerely,

    Cédric Traizet



    _______________________________________________
    gdal-dev mailing list
    [hidden email]
    https://lists.osgeo.org/mailman/listinfo/gdal-dev

    main.cpp (1K) Download Attachment
    Reply | Threaded
    Open this post in threaded view
    |

    Re: Problem when creating GeoTiff raster with null origin and unit spacing

    Even Rouault-2
    Cédric,

    this has been fixed in GDAL 2.3.0
    See https://github.com/OSGeo/gdal/blob/master/gdal/NEWS#L911
    https://github.com/OSGeo/gdal/commit/b28696a29f7c47ca05ffac57a6792a7d3e745e26

    Even

    --
    Spatialys - Geospatial professional services
    http://www.spatialys.com
    _______________________________________________
    gdal-dev mailing list
    [hidden email]
    https://lists.osgeo.org/mailman/listinfo/gdal-dev