Opened 16 years ago

Closed 15 years ago

#2130 closed defect (invalid)

GTiff Driver CreateCopy method creates an all black geotiff

Reported by: jbeiko Owned by: ashrafroni
Priority: normal Milestone:
Component: GDAL_Raster Version: 1.6.0
Severity: normal Keywords: gtiff
Cc: warmerdam

Description (last modified by warmerdam)

(I used the GDAL files from: http://download.osgeo.org/gdal/win32/1.5/)

In my application, I call CreateCopy(...) from the GTiff driver (using a geotiff file, so yes, I'm 'converting' from geotiff to geotiff) and the result is a geotiff that is properly sized and georeferenced, but is all black.

If I use the include/lib/DLLs from FWTools, the file that is created is correct, and is coloured correctly; so this operation works properly in FWTools.

Below is the output from tiffinfo, gdalinfo, and my source code.

TIFFINFO (source file)-----------------
TIFF Directory at offset 0x18000008 (402653192)
  Subfile Type: (0 = 0x0)
  Image Width: 16384 Image Length: 8192
  Resolution: 72, 72 pixels/inch
  Bits/Sample: 8
  Compression Scheme: None
  Photometric Interpretation: RGB color
  Samples/Pixel: 3
  Rows/Strip: 1
  Planar Configuration: single image plane
  Software: Adobe Photoshop 7.0
  DateTime: 2002:05:17 17:33:41
  Tag 33550: 0.021973,0.021973,0.000000
  Tag 33922: 0.000000,0.000000,0.000000,-180.000000,90.000000,0.000000
  Tag 34735: 1,1,0,5,1024,0,1,2,1025,0,1,1,2048,0,1,4326,2052,0,1,9001,2054,0,1,9102


GDALINFO (source file)-----
Driver: GTiff/GeoTIFF
Files: c:\Documents and Settings\jbeiko\Desktop\Worldview DataORIGINAL\World Raster\WorldNight16384.tif
Size is 16384, 8192
Coordinate System is:
GEOGCS["WGS 84",
    DATUM["WGS_1984",
        SPHEROID["WGS 84",6378137,298.2572235630016,
            AUTHORITY["EPSG","7030"]],
        AUTHORITY["EPSG","6326"]],
    PRIMEM["Greenwich",0],
    UNIT["degree",0.0174532925199433],
    AUTHORITY["EPSG","4326"]]
Origin = (-180.000000000000000,90.000000000000000)
Pixel Size = (0.021972656250000,-0.021972656250000)
Metadata:
  AREA_OR_POINT=Area
  TIFFTAG_SOFTWARE=Adobe Photoshop 7.0
  TIFFTAG_DATETIME=2002:05:17 17:33:41
  TIFFTAG_XRESOLUTION=72
  TIFFTAG_YRESOLUTION=72
  TIFFTAG_RESOLUTIONUNIT=2 (pixels/inch)
Corner Coordinates:
Upper Left  (-180.0000000,  90.0000000) (180d 0'0.00"W, 90d 0'0.00"N)
Lower Left  (-180.0000000, -90.0000000) (180d 0'0.00"W, 90d 0'0.00"S)
Upper Right ( 180.0000000,  90.0000000) (180d 0'0.00"E, 90d 0'0.00"N)
Lower Right ( 180.0000000, -90.0000000) (180d 0'0.00"E, 90d 0'0.00"S)
Center      (   0.0000000,   0.0000000) (  0d 0'0.01"E,  0d 0'0.01"N)
Band 1 Block=16384x1 Type=Byte, ColorInterp=Red
Band 2 Block=16384x1 Type=Byte, ColorInterp=Green
Band 3 Block=16384x1 Type=Byte, ColorInterp=Blue


SOURCE CODE-----------

CPLSetConfigOption("GDAL_DATA","C:\\Documents and Settings\\jbeiko\\Desktop\\gdalwin32exe150\\gdalwin32-1.5\\data");

GDALAllRegister();

GDALDataset *poSourceDataset;

poSourceDataset = (GDALDataset *) GDALOpen("C:\\Documents and Settings\\jbeiko\\Desktop\\Worldview DataORIGINAL\\World Raster\\WorldNight16384.tif", GA_ReadOnly);

const char *pszFormat = "GTiff";
GDALDriver *poDriver;
char **papszMetadata;

poDriver = GetGDALDriverManager()->GetDriverByName(pszFormat);

if(poDriver == NULL)
{
  printf("Driver could not be found.");
  return 0;
}

papszMetadata = poDriver->GetMetadata();

if( CSLFetchBoolean( papszMetadata, GDAL_DCAP_CREATE, FALSE ) )
{
  printf( "Driver %s supports Create() method.\n", pszFormat );
}

if( CSLFetchBoolean( papszMetadata, GDAL_DCAP_CREATECOPY, FALSE ) )
{
  printf( "Driver %s supports CreateCopy() method.\n", pszFormat );
}

GDALDataset *poDestinationDataset;

const char *pszDestinationFile = "C:\\Export\\Nighttime.tif";
poDestinationDataset = poDriver->CreateCopy(pszDestinationFile,
		   poSourceDataset, FALSE, NULL, NULL, NULL);

return 0;

Change History (11)

comment:1 by warmerdam, 16 years ago

Component: defaultGDAL_Raster
Description: modified (diff)
Keywords: gtiff added
Status: newassigned
Version: unspecified1.5.0

comment:2 by warmerdam, 15 years ago

Cc: warmerdam added
Owner: changed from warmerdam to ashrafroni
Status: assignednew

Roni,

Please try to reproduce this using the binaries indicated. Ask the reporter questions if you need additional information.

comment:3 by ashrafroni, 15 years ago

I got the whole picture. But can you send me the tiff image file you used?

comment:4 by warmerdam, 15 years ago

Owner: changed from ashrafroni to chaitanya

jbeiko,

I think we will need an input image demonstrating this problem in order to be able to reproduce the problem - ideally a small one easily moved around. I'm turning this over to Chaitanya to reproduce and correct.

comment:5 by ashrafroni , 15 years ago

Which version of compiler is used? VC++ 6.0 or VC++ 2005?

comment:6 by ashrafroni , 15 years ago

Version: 1.5.01.6.0

Hi I successfully created the case. I am solving this.

comment:7 by warmerdam, 15 years ago

Owner: changed from chaitanya to ashrafroni

comment:8 by ashrafroni , 15 years ago

Before return 0; if the following line added then the problem will be solved. I will study more and go through the code.

if( poDestinationDataset != NULL )

GDALClose( poDestinationDataset );

comment:9 by warmerdam, 15 years ago

I concur. Datasets must be explicitly closed to cause outstanding information to be flushed out.

comment:10 by Even Rouault, 15 years ago

Typically, GeoTIFF driver does finish writing a lot of important things at dataset closing (C++ object destruction). So this is required.

comment:11 by Even Rouault, 15 years ago

Resolution: invalid
Status: newclosed

Closing. Not a GDAL library issue, but user application instead

Note: See TracTickets for help on using tickets.