[gdal-dev] projection error

Even Rouault even.rouault at spatialys.com
Tue Sep 8 05:56:18 PDT 2015


Le mardi 08 septembre 2015 14:43:51, y hema a écrit :
> hi ,
> poDataset = (GDALDataset *) GDALOpen( pszFilename, GA_ReadOnly );
> 
>     if( poDataset != NULL )
>     {
>         numBands = poDataset->GetRasterCount();
>         width = poDataset->GetRasterXSize();
>         height = poDataset->GetRasterYSize();
>         GDALRasterBand  *poBand;
>         poBands = new GDALRasterBand*[numBands];
> 
> 
>         poBand = poDataset->GetRasterBand(1);
> 
>         dataType = (GDALDataType)poBand->GetRasterDataType();
>         bytesPerPixel =GDALGetDataTypeSize((GDALDataType)dataType)/8;
>     }
>     const char *ch =   poDataset->GetProjectionRef();
>     double *tiepoints = new double[6];
>     poDataset->GetGeoTransform(tiepoints);
>     for(int i=0;i<6;i++)
>     {
>         qDebug()<<"tie points"<< tiepoints[0];
>     }
>     uchar *data;
> 
>     data = (uchar *) /*CPLMalloc*/new
> char[(sizeof(uchar)*width*height*bytesPerPixel*numBands)];
>     int bandIndices[numBands];
>     double scale = 5.0;
> 
>     for(int j=0 ;j<numBands ;j++)
>     {
>         bandIndices[j] = j;
>     }
>     for(int i = 0; i < numBands; i++)
>     {
>         poBands[i] = poDataset->GetRasterBand(bandIndices[i]+1);
>         poBands[i]->SetScale(10);
> 
>         poBands[i]->RasterIO(GF_Read, 0, 0, width,
> height,data+(bytesPerPixel*i), width, height, (GDALDataType)dataType,
> numBands*bytesPerPixel, 0);
> 
>     }
> 
> 
> actually i am trying to read the projection string and the tie points .the
> above is the code im using.

I don't see how the above code would cause the "Only OGC WKT Projections 
supported for writing to GeoTIFF" error to be emitted. This error can only be 
raised if you call SetProjection(). Here you call GetProjectionRef() (which is 
fine if your intent is to read the projection string).
In the above code, I can just tell that SetScale() call will be without effect: 
you likely want the RasterIO() to return values multiplied by 10, but 
SetScale() just set a sort of metadata that has no effect on the returned 
values and only makes sense when you create/modify a raster.

Even

-- 
Spatialys - Geospatial professional services
http://www.spatialys.com


More information about the gdal-dev mailing list