Opened 16 years ago

Last modified 15 years ago

#2130 closed defect

GTiff Driver CreateCopy method creates an all black geotiff — at Version 1

Reported by: jbeiko Owned by: warmerdam
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 (1)

comment:1 by warmerdam, 16 years ago

Component: defaultGDAL_Raster
Description: modified (diff)
Keywords: gtiff added
Status: newassigned
Version: unspecified1.5.0
Note: See TracTickets for help on using tickets.