[gdal-dev] ``HDF4Image: Can't get the list of geolocation maps in swath mod07''

Ivan Shmakov oneingray at gmail.com
Tue Dec 11 06:14:53 EST 2007


>>>>> Andrey Kiselev <dron at ak4719.spb.edu> writes:

[...]

 >> Perhaps, it causes the following:

 >> $ CPL_DEBUG=ON GEOL_AS_GCPS=FULL \
 >>       gdal_translate \
 >>           'HDF4_EOS:EOS_SWATH:"MOD07_L2.hdf":mod07:Tropopause_Height' \
 >>           mod07-l2.tropopause-height.tiff
 >> ...
 >> HDF4Image: Can't get the list of geolocation maps in swath mod07
 >> ...

 > Ivan,

 > Could you make your HDF file available?

        Surely.

http://theory.asu.ru/~ivan/modis/MOD07_L2.hdf

 > I think the real problem is somwhere else.

        Indeed, it is.

        I've tried to trace the problem and have stumbled upon the
        following.

$ nl -ba gdal/frmts/hdf4/hdf4imagedataset.cpp
...
  1608  /* --------------------------------------------------------------------
*/
  1609  /*      xx
         */
  1610  /* --------------------------------------------------------------------
*/
  1611      nDataFields = SWnentries( hSW, HDFE_NENTGFLD, &nStrBufSize );

        This call correctly returns `2'...

...
  1615      if ( nDataFields !=
  1616           SWinqgeofields(hSW, pszGeoList, paiRank, paiNumType) )

        ... and this one fills `pszGeoList' with `Latitude,Longitude'.

  1617      {
...
  1621      }
...
  1643      // Read geolocation data
  1644      nDimMaps = SWnentries( hSW, HDFE_NENTMAP, &nStrBufSize );

        However, there `0' is returned...

...
  1652      if ( nDimMaps == 0
  1653           || nDimMaps != SWinqmaps(hSW, pszDimMaps, paiOffset,
paiIncrement) )
  1654      {
  1655          CPLDebug( "HDF4Image",
  1656                    "Can't get the list of geolocation maps in swath %s",
  1657                    pszSubdatasetName );

        ... which leads to this message being printed...

  1658      }
...
  1683      papszDimMap = CSLTokenizeString2( pszDimMaps, ",",
  1684                                        CSLT_HONOURSTRINGS );
  1685      CPLFree( pszDimMaps );
  1686      pszDimMaps = NULL;
  1687      pszDimMaps = NULL;
  1688      for ( i = 0; i < CSLCount(papszDimMap); i++ )
  1689      {

        ... and for this body to be never executed.

  1690          if ( strstr(papszDimMap[i], papszDimList[iXDim]) )
  1691          {
  1692              strncpy( szPixel, papszDimList[iXDim], 8192 );
  1693              strncpy( szXGeo, papszDimMap[i], 8192 );
...
  1697          }
  1698          else if ( strstr(papszDimMap[i], papszDimList[iYDim]) )
  1699          {
  1700              strncpy( szLine, papszDimList[iYDim], 8192 );
  1701              strncpy( szYGeo, papszDimMap[i], 8192 );
...
  1705          }

        So, both `szXGeo' and `szYGeo' are never touched...

  1706      }
  1707      CSLDestroy( papszDimMap );
  1708      papszDimMap = NULL;
  1709      papszDimMap = NULL;
  1710      for ( i = 0; i < CSLCount(papszGeolocations); i++ )
  1711      {
  1712          char    **papszGeoDimList = NULL;
  1713          char    **papszGeoDimList = NULL;
  1714          SWfieldinfo( hSW, papszGeolocations[i], &iRank,
  1715                       aiDimSizes, &iWrkNumType, szGeoDimList );
  1716          papszGeoDimList = CSLTokenizeString2( szGeoDimList,
  1717                                                ",", CSLT_HONOURSTRINGS );
  1718                                                ",", CSLT_HONOURSTRINGS );
  1719  #if DEBUG
  1720          CPLDebug( "HDF4Image",
  1721                    "List of dimensions in geolocation field %s: %s",
  1722                    papszGeolocations[i], szGeoDimList );
  1723  #endif
  1724  #endif
  1725          if (szXGeo[0] == 0 || szYGeo[0] == 0)
  1726              return FALSE;

        ... and the function does return here.

  1727  ... and the function does return here.
  1728          nXPoints = aiDimSizes[CSLFindString( papszGeoDimList, szXGeo )];
  1729          nYPoints = aiDimSizes[CSLFindString( papszGeoDimList, szYGeo )];
...
$


More information about the gdal-dev mailing list