[Gdal-dev] projection conversion problems
Mote, Kevin D
Kevin.Mote at pnl.gov
Mon May 15 16:26:17 EDT 2006
newbie question here.
I'm trying to convert a .jpg (with an associated .prj file) into a
geoTiff.
Code looks like this:
// Load the reference image
m_pGDB = (GDALDataset*)GDALOpenShared( CStringA(jpg_FileName),
GA_ReadOnly );
// Get a GTiff driver object
GDALDriver *poDriver;
poDriver = GetGDALDriverManager()->GetDriverByName("GTiff");
// Create the GTiff file
GDALDataset *poDstDS;
poDstDS = poDriver->CreateCopy( CStringA(tif_Filename), m_pGDB,
FALSE, NULL, NULL, NULL );
// Set the projection information in the GTiff
err = poDstDS->SetProjection( CStringA(m_ProjectionRef) );
VERIFY( err == OGRERR_NONE );
// Close
GDALClose( poDstDS );
The original projection string looks like this:
PROJCS["Custom",GEOGCS["GCS_WGS_1984",DATUM["WGS_1984",SPHEROID["WGS_198
4",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.017
4532925199433]],PROJECTION["Azimuthal_Equidistant"],PARAMETER["False_Eas
ting",0.0],PARAMETER["False_Northing",0.0],PARAMETER["Longitude_Of_Origi
n",16.11111111111111],PARAMETER["Latitude_Of_Origin",2.777777777777776],
UNIT["Meter",1.0]]
The newly created geotiff projection string looks like this:
PROJCS["Custom",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],AUTHOR
ITY["EPSG","4326"]],PROJECTION["Azimuthal_Equidistant"],PARAMETER["latit
ude_of_center",0],PARAMETER["longitude_of_center",0],PARAMETER["false_ea
sting",0],PARAMETER["false_northing",0],UNIT["metre",1,AUTHORITY["EPSG",
"9001"]]]
(Note the "longitude_of_center" is 0, when the original had a
"Longitude_Of_Origin" as 16.111111; similarly with latitude). The
problem seems to be associated with particular Projections
(Azimuthal_Equidistant in this example, but I've also had similar
troubles with Robinson and Miller Cylindrical. With other projections,
however, the code seems to work just fine. It's as if the GDALDriver is
failing to copy the information because the attribute name is
non-standard. Or perhaps I'm just doing something wrong. Do you have any
suggestions for me?
Thanks!
Kevin Mote
More information about the Gdal-dev
mailing list