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

Cédric Traizet cedric.traizet at c-s.fr
Tue Mar 26 02:47:05 PDT 2019


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


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20190326/ad9fbf9b/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: main.cpp
Type: text/x-c++src
Size: 1792 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20190326/ad9fbf9b/attachment-0001.cpp>


More information about the gdal-dev mailing list