[gdal-dev] HDF4 file in byte array results in "not recognised" error

Even Rouault even.rouault at mines-paris.org
Mon Jan 24 15:54:35 EST 2011


Sam,

not all drivers support the vsi virtual file systems, such as /vsimem. And HDF4 
is one of those drivers (the HDF4 libs need a "real" filename). You can 
generally check if a file system supports vsi virtual file systems by issuing 
"gdalinfo --format name_of_driver"

For a compatible driver (such as VRT, but not HDF4), you'll see :
  Supports: Virtual IO - eg. /vsimem/

> Hey all,
> 
> I'm working on an app that needs to pass HDF4 files (MODIS tiles) around as
> byte arrays, and then open them up using gdal#Open, from java. Open works
> great when I pass in the filepath, so I know that my gdal setup is solid.
> 
> The problem is, when I turn the HDF4 file into a byte array and try to use
> 
> gdal.FileFromMemBuffer("/vsimem/test.hdf", bytearray);
> DataSet data = gdal.Open("/vsimem/test.hdf");
> 
> I get an error that reads: "`/vsimem/test.hdf' not recognised as a
> supported file format."
> 
> I tried something similar, by converting
> 
> <VRTDataset rasterXSize=\"1\" rasterYSize=\"1\">
>   <GeoTransform>100,1,0,100,0,-1</GeoTransform>
>   <VRTRasterBand dataType=\"Byte\" band=\"1\">
>   </VRTRasterBand>
> </VRTDataset>
> 
> to a byte array and reading it in, and that worked great.
> 
> Any ideas on how to deal with this issue? I'll note that open SEES the file
> in the /vsimem/ directory, it just doesn't recognize it as a valid file. Is
> this an issue with HDF4 files, or with large binary sequences? Any ideas on
> how to get around this?
> 
> Thanks, all,
> Sam


More information about the gdal-dev mailing list