Prev: a better way to extract data from XHTML (XML)
Next: Calling readline functions from a bash script
From: Ivan Shmakov on 15 Apr 2010 10:57 >>>>> Brendan <brendandetracey(a)yahoo.com> writes: >>>>> Ivan Shmakov <i...(a)main.uusia.org> wrote: [...] >> BTW, speaking of the HDF-EOS files, is there a way to extract >> metadata, more straightforward than, say, the Shell functions below? >> (Converting the metadata to XML may be the way, but the conversion >> software I've found is apparently non-free, Java-based, and failed >> to process the files we've tried it on.) >> $ file=ladsweb.nascom.nasa.gov/allData/5/MOD08_M3/2010/032/MOD08_M3.A2010032.�005.2010062234836.hdf >> $ hdfeos_metadata_get_quoted_scalar "$file" RANGEBEGINNINGDATE >> 2010-02-01 >> $ hdfeos_metadata_get_quoted_scalar "$file" RANGEENDINGDATE >> 2010-03-01 >> $ [...] > I can't give a definite answer because I use Matlab to read hdf. I > don't know much about hdf4 format. If the bytes you seek are always > in the same position in the file I would use bash command "od" to > extract. The HDF-EOS format is, basically, a convention of using specific global attributes to hold certain metadata items. The metadata is represented using (an) Object Description Language (ODL), like: $ ncget-hdf -T "$file" :CoreMetadata.0 GROUP = INVENTORYMETADATA GROUPTYPE = MASTERGROUP GROUP = ECSDATAGRANULE OBJECT = LOCALGRANULEID NUM_VAL = 1 VALUE = "MOD08_M3.A2010032.005.2010062234836.hdf" END_OBJECT = LOCALGRANULEID [...] END_GROUP = ECSDATAGRANULE [...] END_GROUP = INVENTORYMETADATA END $ As one could see, it's not a trivial thing to parse. (Luckily, as present in the most files I've seen, certain extra conditions are met, so I could simplify the parsing down to the ways easily implementable using Sed.) > Otherwise gdal tool gdalinfo might do the trick. Well, indeed, it does. Though I'd prefer a more light-weight solution. > Can install from scratch or grab an FWTools build. # apt-get install gdal-bin does it for me. > Good Luck! -- FSF associate member #7257
|
Pages: 1 Prev: a better way to extract data from XHTML (XML) Next: Calling readline functions from a bash script |