Click here to Skip to main content
15,885,757 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Quote:
Hello everyone, i am using the GDAL library to write a GeoTiff file and then I achieved some result and result is good as you can see on below but I want a RGB GeoTiff image. If you click on this lick you can see the result. "http://tinypic.com/r/aomfs5/9"


C++
GDALDataset* newDataSet;
GDALDriver*  driverTiff;
driverTiff = GetGDALDriverManager()->GetDriverByName( "GTiff" );
newDataSet = driverTiff->Create( "New file name", _col, _row, 1, GDT_Float32, NULL ); 

double adfGeoTransform[ 6 ] = { -5500000, 4000, 0, 5500000, 0, -4000 };
newDataSet->SetGeoTransform( adfGeoTransform );

float* newRow = ( float* ) CPLMalloc( sizeof( float ) * _col );
	
float fMax = pow( 2.0, 10 );
float fRange = fMax - 1;
float fRate = (float)256 / fRange; 

for( int i = 0; i < _row; i++ )
	{
		for( int j = 0; j < _col; j++ )
		{
			int val = _dataD[ i * _col + j ];->"I am getting the data from here"
			int value = (int)( 0.5 + val * fRate );

			if( value < 0 ) value = 0;
			if( value > 255 ) value = 255;

			newRow[ j ] = value;
		}
newDataSet->GetRasterBand( 1 )->RasterIO( GF_Write, 0, i, _col, 1, newRow, _col, 1, GDT_Float32, 0, 0 );
	
	}
newDataSet->SetProjection("WGS84");

GDALClose( newDataSet );
GDALDestroyDriverManager();


What I have tried:

Create a GeoTiff image based on the GDAl library
Posted
Comments
Sergey Alexandrovich Kryukov 18-Apr-16 23:10pm    
Sorry, we cannot handle non-questions.
—SA
Sukerbek 19-Apr-16 20:55pm    
I have a solved my problem
Member 10271796 29-Jun-17 6:07am    
Solved, HOW ?
Sukerbek 1-Nov-17 21:57pm    
Just i have created image and then i added some meta data to the image file.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900