H5T_STRING 的 hdf5dump

发布于 2024-12-12 19:01:01 字数 676 浏览 0 评论 0原文

我试图弄清楚如何从 HDF5 文件(测深属性网格/BAG)转储文本块。当我执行 h5dump -d /BAG_root/metadata H11703_Office_5m.bag 以及我尝试过的任何其他操作时,我总是会获取引用 XML 的每个字符的数据。是否有一个“简单”选项可以将原始数据内容转储到文件或终端?

DATASET "/BAG_root/metadata" {
   DATATYPE  H5T_STRING {
         STRSIZE 1;
         STRPAD H5T_STR_NULLTERM;
         CSET H5T_CSET_ASCII;
         CTYPE H5T_C_S1;
      }
   DATASPACE  SIMPLE { ( 5097 ) / ( H5S_UNLIMITED ) }
   DATA {
   (0): "<", "?", "x", "m", "l", " ", "v", "e", "r", "s", "i", "o", "n", "=",
   (14): """, "1", ".", "0", """, "?", ">", "
           ", "<", "s", "m",
   (25): "X", "M", "L", ":", "M", "D", "_", "M", "e", "t", "a", "d", "a",

I'm trying to figure out how to dump a text block from an HDF5 file (a Bathymetric Attributed Grid / BAG). When I do h5dump -d /BAG_root/metadata H11703_Office_5m.bag, and anything else I've tried, I always get the data with each character of the XML quoted. Is there an "easy" option to have it dump the raw data contents to a file or the terminal?

DATASET "/BAG_root/metadata" {
   DATATYPE  H5T_STRING {
         STRSIZE 1;
         STRPAD H5T_STR_NULLTERM;
         CSET H5T_CSET_ASCII;
         CTYPE H5T_C_S1;
      }
   DATASPACE  SIMPLE { ( 5097 ) / ( H5S_UNLIMITED ) }
   DATA {
   (0): "<", "?", "x", "m", "l", " ", "v", "e", "r", "s", "i", "o", "n", "=",
   (14): """, "1", ".", "0", """, "?", ">", "
           ", "<", "s", "m",
   (25): "X", "M", "L", ":", "M", "D", "_", "M", "e", "t", "a", "d", "a",

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

忆伤 2024-12-19 19:01:01

当我在 OpenNavSurf 邮件列表上提出这个主题后,Marcus Cole 通过电子邮件向我发送了这个解决方案:

h5dump -b FILE -o H12279_VB_4m_MLLW_1of1.xml -d BAG_root/metadata H12279_VB_4m_MLLW_1of1.bag

这会写出一个干净的 XML 文件。

Marcus Cole emailed me this solution after I brought up the topic on the OpenNavSurf mailing list:

h5dump -b FILE -o H12279_VB_4m_MLLW_1of1.xml -d BAG_root/metadata H12279_VB_4m_MLLW_1of1.bag

This writes out a clean XML file.

岁月静好 2024-12-19 19:01:01

回复:Python 和BAG,GDAL 1.7.0+支持BAG格式;例如:

from osgeo import gdal
bag = gdal.OpenShared(r"C:\DATA\NGDC\H11555_2m_1.bag")
bagmetadata = bag.GetMetadata("xml:BAG")[0]

Re: Python & BAG, GDAL 1.7.0+ supports the BAG format; e.g.:

from osgeo import gdal
bag = gdal.OpenShared(r"C:\DATA\NGDC\H11555_2m_1.bag")
bagmetadata = bag.GetMetadata("xml:BAG")[0]
青柠芒果 2024-12-19 19:01:01

数据存储为 5097 个单字符串数组 (STRSIZE 1)。要转储文本,它应该存储为真实字符串(例如,在标量数据空间中)。

因此,我认为您不能单独使用 h5dump 来完成此操作,您可能必须使用 sed 或您最喜欢的正则表达式工具来处理转储。

The data is stored as an array of 5097 single characters strings (STRSIZE 1). To dump the text, it should have been stored as a real string (e.g. in a scalar dataspace).

So I think you cannot do it with h5dump alone, you probably have to process the dump with sed or your favorite regexp tool.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文