Your help is invaluable, thanks again. Christiaan
-----Original Message----- From: Frank Warmerdam [mailto:[EMAIL PROTECTED] Sent: Friday, July 25, 2008 4:54 PM To: Christiaan Janssen Cc: [email protected] Subject: Re: [gdal-dev] CADRG subdataset access help Christiaan Janssen wrote: > I'm working programmatically. I sort of understand the mechanism described in > the suggested document but would greatly appreciate a short snippet to show > how one goes about opening the subdataset. I'm guessing in the example > described on the web page that to open the first dataset I would call > GDALOpen as follows: > > GDALOpen("NITF_IM:0:multi_1b.ntf", GDALAccess::GA_ReadOnly); Christiaan, Yes, though you don't normally need to qualify GA_ReadOnly. The following code chunk out of gdal_translate (used to recurse over subdatasets) might also be helpful. /* -------------------------------------------------------------------- */ /* Handle subdatasets. */ /* -------------------------------------------------------------------- */ if( CSLCount(GDALGetMetadata( hDataset, "SUBDATASETS" )) > 0 ) { if( !bCopySubDatasets ) { fprintf( stderr, "Input file contains subdatasets. Please, select one of them for reading.\n" ); } else { char **papszSubdatasets = GDALGetMetadata(hDataset,"SUBDATASETS"); char *pszSubDest = (char *) CPLMalloc(strlen(pszDest)+32); int i; int bOldSubCall = bSubCall; argv[iDstFileArg] = pszSubDest; bSubCall = TRUE; for( i = 0; papszSubdatasets[i] != NULL; i += 2 ) { argv[iSrcFileArg] = strstr(papszSubdatasets[i],"=")+1; sprintf( pszSubDest, "%s%d", pszDest, i/2 + 1 ); if( ProxyMain( argc, argv ) != 0 ) break; } bSubCall = bOldSubCall; CPLFree( pszSubDest ); } GDALClose( hDataset ); if( !bSubCall ) { GDALDumpOpenDatasets( stderr ); GDALDestroyDriverManager(); } return 1; } -- ---------------------------------------+-------------------------------- ---------------------------------------+------ I set the clouds in motion - turn up | Frank Warmerdam, [EMAIL PROTECTED] light and sound - activate the windows | http://pobox.com/~warmerdam and watch the world go round - Rush | President OSGeo, http://osgeo.org _______________________________________________ gdal-dev mailing list [email protected] http://lists.osgeo.org/mailman/listinfo/gdal-dev
