[gdal-dev] GDAL created HFA images unreadable in ERDAS ViewFinder
jeepingben
ben_deering at swissmail.org
Wed Dec 15 11:41:10 EST 2010
I am working on converting a NITF to imagine format using GDAL 1.7.2. I can
create files that are readble and seem to be correct in my program and
according to gdalinfo and hfatest, but they do not open in ViewFinder. If I
dumb down the geotransform so that a mapinfo node is added to the output
image, it works in ViewFinder, but rotation information about the image is
lost.
Here is the relevant code:
<code>
poDstDS = poDriver->Create( outputNameAndPath, nXSize, nYSize, nBands,
eType,
papszOptions );
// populate additional fields in the hfadataset
double affine[6];
OGRSpatialReference oSRS;
affine[0] = image->ul_corner[1];
affine[1] = (image->ur_corner[1] - image->ul_corner[1]) /
image->image_cols ;
affine[2] = (image->ll_corner[1] - image->ul_corner[1]) /
image->image_rows ;
affine[3] = image->ul_corner[0];
affine[4] = ( image->ur_corner[0] - image->ul_corner[0] ) /
image->image_cols ;
affine[5] = ( image->ul_corner[0] - image->ll_corner[0] ) /
image->image_rows ;
poDstDS->SetGeoTransform( affine );
// from the spec:
// This may be called on an empty OGRSpatialReference to make a
geographic coordinate system
oSRS.SetWellKnownGeogCS( "WGS84" );
char *pszSRS_WKT = NULL;
int copyXsize = 0;
int copyYsize = 0;
oSRS.exportToWkt( &pszSRS_WKT );
poDstDS->SetProjection( pszSRS_WKT );
...
GDALClose( (GDALDatasetH) poDstDS );
</code>
If I replace affine[2] and affine[4] with 0.0 I get a readable file, but any
rotation information is lost so the transform is wrong. If I leave them in,
my program (and the gdal programs) can open the image and the transform
seems to be correct, but the imagine viewer cannot open the file (it says
'Not enough projection info available').
This is what hfatest says about the image that doesnt load:
root(root) @ 27600905 + 0 @ 0
IMGFormatInfo(ImgFormatInfo831) @ 27601033 + 4 @ 27601161
+ spaceUsedForRasterData = 27549696
Layer_1(Eimg_Layer) @ 27601165 + 20 @ 27601293
+ width = 3587
+ height = 3716
+ layerType = athematic
+ pixelType = u16
+ blockWidth = 64
+ blockHeight = 64
RasterDMS(Edms_State) @ 3802 + 47120 @ 3930
+ numvirtualblocks = 3363
+ numobjectsperblock = 4096
+ nextobjectnum = 13774848
+ compressionType = no compression
+ blockinfo[0] =
+ fileCode = 0
+ offset = 51050
+ size = 8192
+ logvalid = true
+ compressionType = no compression
+ blockinfo[1] =
+ fileCode = 0
+ offset = 59242
+ size = 8192
+ logvalid = true
+ compressionType = no compression
+ blockinfo[2] =
+ fileCode = 0
+ offset = 67434
+ size = 8192
+ logvalid = true
+ compressionType = no compression
+ blockinfo[3] =
+ fileCode = 0
+ offset = 75626
+ size = 8192
+ logvalid = true
+ compressionType = no compression
+ blockinfo[4] =
+ fileCode = 0
+ offset = 83818
+ size = 8192
+ logvalid = true
+ compressionType = no compression
+ blockinfo[5] =
+ fileCode = 0
+ offset = 92010
+ size = 8192
+ logvalid = true
+ compressionType = no compression
+ blockinfo[6] =
+ fileCode = 0
+ offset = 100202
+ size = 8192
+ logvalid = true
+ compressionType = no compression
+ blockinfo[7] =
+ fileCode = 0
+ offset = 108394
+ size = 8192
+ logvalid = true
+ compressionType = no compression
+ blockinfo[8] =
+ fileCode = 0
+ offset = 116586
+ size = 8192
+ logvalid = true
+ compressionType = no compression
+ blockinfo[9] =
+ fileCode = 0
+ offset = 124778
+ size = 8192
+ logvalid = true
+ compressionType = no compression
+ blockinfo[10] =
+ fileCode = 0
+ offset = 132970
+ size = 8192
+ logvalid = true
+ compressionType = no compression
+ blockinfo[11] =
+ fileCode = 0
+ offset = 141162
+ size = 8192
+ logvalid = true
+ compressionType = no compression
+ blockinfo[12] =
+ fileCode = 0
+ offset = 149354
+ size = 8192
+ logvalid = true
+ compressionType = no compression
+ blockinfo[13] =
+ fileCode = 0
+ offset = 157546
+ size = 8192
+ logvalid = true
+ compressionType = no compression
+ blockinfo[14] =
+ fileCode = 0
+ offset = 165738
+ size = 8192
+ logvalid = true
+ compressionType = no compression
+ blockinfo[15] =
+ fileCode = 0
+ offset = 173930
+ size = 8192
+ logvalid = true
+ compressionType = no compression
+ ... remaining instances omitted ...
+ freelist = (no values)
+ modTime = 0
Ehfa_Layer(Ehfa_Layer) @ 27600746 + 6 @ 27600874
+ type = raster
+ dictionaryPtr = 27600880
ProjectionX(Eprj_MapProjection842) @ 27601313 + 843 @ 27601441
+ projection =
+ type =
+ string = `PE_COORDSYS'
+ MIFDictionary =
+ string =
`{0:pcstring,}Emif_String,{1:x{0:pcstring,}Emif_String,coordSys,}PE_COORDSYS,.'
+ MIFObject = `'
+ title =
+ string = `PE'
MapInformation(Eimg_MapInformation) @ 27602284 + 40 @ 27602412
+ projection =
+ string = `Geographic (Lat/Lon)'
+ units =
+ string = `dd'
MapToPixelXForm(Exfr_GenericXFormHeader) @ 27602452 + 23 @ 27602580
+ titleList =
+ string = `Affine'
XForm0(Efga_Polynomial) @ 27602603 + 136 @ 27602731
+ order = 1
+ numdimtransform = 2
+ numdimpolynomial = 2
+ termcount = 3
+ exponentlist[0] = 0
+ exponentlist[1] = 0
+ exponentlist[2] = 1
+ exponentlist[3] = 0
+ exponentlist[4] = 0
+ exponentlist[5] = 1
+ BASEDATA(polycoefmtx): 2x2 of f64
+ polycoefmtx[0] = + 21973.1640671877
+ polycoefmtx[1] = + -519.496437926653
+ polycoefmtx[2] = + -638.224682450435
+ polycoefmtx[3] = + 27769.4459546298
+ BASEDATA(polycoefvector): 1x2 of f64
+ polycoefvector[0] = + -2761223.74395772
+ polycoefvector[1] = + -990232.403820546
Projection(Eprj_ProParameters) @ 27602867 + 230 @ 27602995
+ proType = EPRJ_INTERNAL
+ proNumber = 0
+ proExeName = (no values)
+ proName = `Geographic (Lat/Lon)'
+ proZone = 0
+ proParams[0] = 0.000000
+ proParams[1] = 0.000000
+ proParams[2] = 0.000000
+ proParams[3] = 0.000000
+ proParams[4] = 0.000000
+ proParams[5] = 0.000000
+ proParams[6] = 0.000000
+ proParams[7] = 0.000000
+ proParams[8] = 0.000000
+ proParams[9] = 0.000000
+ proParams[10] = 0.000000
+ proParams[11] = 0.000000
+ proParams[12] = 0.000000
+ proParams[13] = 0.000000
+ proParams[14] = 0.000000
+ proSpheroid =
+ sphereName = `WGS 84'
+ a = 6378137.000000
+ b = 6356752.314245
+ eSquared = 0.006694
+ radius = 6378137.000000
Datum(Eprj_Datum) @ 27603225 + 89 @ 27603353
+ datumname = `WGS 84'
+ type = EPRJ_DATUM_PARAMETRIC
+ params[0] = 0.000000
+ params[1] = 0.000000
+ params[2] = 0.000000
+ params[3] = 0.000000
+ params[4] = 0.000000
+ params[5] = 0.000000
+ params[6] = 0.000000
+ gridname = (no values)
=========================================================
And here is the one that works:
root(root) @ 27600905 + 0 @ 0
IMGFormatInfo(ImgFormatInfo831) @ 27601033 + 4 @ 27601161
+ spaceUsedForRasterData = 27549696
Layer_1(Eimg_Layer) @ 27601165 + 20 @ 27601293
+ width = 3587
+ height = 3716
+ layerType = athematic
+ pixelType = u16
+ blockWidth = 64
+ blockHeight = 64
RasterDMS(Edms_State) @ 3802 + 47120 @ 3930
+ numvirtualblocks = 3363
+ numobjectsperblock = 4096
+ nextobjectnum = 13774848
+ compressionType = no compression
+ blockinfo[0] =
+ fileCode = 0
+ offset = 51050
+ size = 8192
+ logvalid = true
+ compressionType = no compression
+ blockinfo[1] =
+ fileCode = 0
+ offset = 59242
+ size = 8192
+ logvalid = true
+ compressionType = no compression
+ blockinfo[2] =
+ fileCode = 0
+ offset = 67434
+ size = 8192
+ logvalid = true
+ compressionType = no compression
+ blockinfo[3] =
+ fileCode = 0
+ offset = 75626
+ size = 8192
+ logvalid = true
+ compressionType = no compression
+ blockinfo[4] =
+ fileCode = 0
+ offset = 83818
+ size = 8192
+ logvalid = true
+ compressionType = no compression
+ blockinfo[5] =
+ fileCode = 0
+ offset = 92010
+ size = 8192
+ logvalid = true
+ compressionType = no compression
+ blockinfo[6] =
+ fileCode = 0
+ offset = 100202
+ size = 8192
+ logvalid = true
+ compressionType = no compression
+ blockinfo[7] =
+ fileCode = 0
+ offset = 108394
+ size = 8192
+ logvalid = true
+ compressionType = no compression
+ blockinfo[8] =
+ fileCode = 0
+ offset = 116586
+ size = 8192
+ logvalid = true
+ compressionType = no compression
+ blockinfo[9] =
+ fileCode = 0
+ offset = 124778
+ size = 8192
+ logvalid = true
+ compressionType = no compression
+ blockinfo[10] =
+ fileCode = 0
+ offset = 132970
+ size = 8192
+ logvalid = true
+ compressionType = no compression
+ blockinfo[11] =
+ fileCode = 0
+ offset = 141162
+ size = 8192
+ logvalid = true
+ compressionType = no compression
+ blockinfo[12] =
+ fileCode = 0
+ offset = 149354
+ size = 8192
+ logvalid = true
+ compressionType = no compression
+ blockinfo[13] =
+ fileCode = 0
+ offset = 157546
+ size = 8192
+ logvalid = true
+ compressionType = no compression
+ blockinfo[14] =
+ fileCode = 0
+ offset = 165738
+ size = 8192
+ logvalid = true
+ compressionType = no compression
+ blockinfo[15] =
+ fileCode = 0
+ offset = 173930
+ size = 8192
+ logvalid = true
+ compressionType = no compression
+ ... remaining instances omitted ...
+ freelist = (no values)
+ modTime = 0
Ehfa_Layer(Ehfa_Layer) @ 27600746 + 6 @ 27600874
+ type = raster
+ dictionaryPtr = 27600880
ProjectionX(Eprj_MapProjection842) @ 27601313 + 843 @ 27601441
+ projection =
+ type =
+ string = `PE_COORDSYS'
+ MIFDictionary =
+ string =
`{0:pcstring,}Emif_String,{1:x{0:pcstring,}Emif_String,coordSys,}PE_COORDSYS,.'
+ MIFObject = `'
+ title =
+ string = `PE'
Map_Info(Eprj_MapInfo) @ 27602284 + 112 @ 27602412
+ proName = `Geographic (Lat/Lon)'
+ upperLeftCenter =
+ x = 126.768078
+ y = 38.030574
+ lowerRightCenter =
+ x = 126.931366
+ y = 38.164426
+ pixelSize =
+ width = 0.000046
+ height = 0.000036
+ units = `dd'
Projection(Eprj_ProParameters) @ 27602524 + 230 @ 27602652
+ proType = EPRJ_INTERNAL
+ proNumber = 0
+ proExeName = (no values)
+ proName = `Geographic (Lat/Lon)'
+ proZone = 0
+ proParams[0] = 0.000000
+ proParams[1] = 0.000000
+ proParams[2] = 0.000000
+ proParams[3] = 0.000000
+ proParams[4] = 0.000000
+ proParams[5] = 0.000000
+ proParams[6] = 0.000000
+ proParams[7] = 0.000000
+ proParams[8] = 0.000000
+ proParams[9] = 0.000000
+ proParams[10] = 0.000000
+ proParams[11] = 0.000000
+ proParams[12] = 0.000000
+ proParams[13] = 0.000000
+ proParams[14] = 0.000000
+ proSpheroid =
+ sphereName = `WGS 84'
+ a = 6378137.000000
+ b = 6356752.314245
+ eSquared = 0.006694
+ radius = 6378137.000000
Datum(Eprj_Datum) @ 27602882 + 89 @ 27603010
+ datumname = `WGS 84'
+ type = EPRJ_DATUM_PARAMETRIC
+ params[0] = 0.000000
+ params[1] = 0.000000
+ params[2] = 0.000000
+ params[3] = 0.000000
+ params[4] = 0.000000
+ params[5] = 0.000000
+ params[6] = 0.000000
+ gridname = (no values)
I have sent my broken image to someone with the full version of Imagine, so
hopefully I will have a more detailed error message soon.
Thanks for your help,
Ben
--
View this message in context: http://osgeo-org.1803224.n2.nabble.com/GDAL-created-HFA-images-unreadable-in-ERDAS-ViewFinder-tp5838122p5838122.html
Sent from the GDAL - Dev mailing list archive at Nabble.com.
More information about the gdal-dev
mailing list