Hi Vikram,

Isn't Aster HDF not  an HDF4 format (like MODIS)? HDF4 and HDF5 are not really comparable/compatible each to other.

If I'm right, you can open the file using GDAL, or even with the raster package, but you have to point the path to the layer (SDS) and not only to the file. There was a discussion between Robert Hijmans and Jan Verbesselt about that... https://r-forge.r-project.org/forum/message.php?msg_id=4132&group_id=294

I think you can do the same with ASTER data.

So now the only problem should be how to get the path to the SDS:
in the MODIS package we use the function: getSDS(HdfName,method='gdal') , try to insert the full FILE-path in that function. 
Or you can try (on windows) with: 
sdsRaw <- shell(paste("gdalinfo ", HdfName,sep=""),intern=TRUE)
SDSnames <- grep(x=sdsRaw,pattern="SUBDATASET_*.._NAME",value=T)
SDSnames <- unlist(lapply(SDSnames,function(x) strsplit(x,"=")[[1]][2]))

at least the sdsRaw should work...SDSnames I don't know, just test it (and maybe give me a short feedback)

If everything runs fine you should be able to open in then raster package like that:

SDS1 <-raster(SDSnames[1]) # you can ignore the warning: normalizePath(x) 
or
sds250 <- stack(SDSnames[1:2]) # FOR MODIS! (only layers with the same resolution are 'stackable')
....

Matteo


So first you have to determinatate the full path to the SDS you wand to extract. 

>>> Vikram Ranga  26.01.12 10.20 Uhr >>>
Hello Paul,
sorry for abstruse mail. I am using R version 2.13.2 on windows (64 
bit). I am trying to open ASTER data files(*.hdf). Though, I tried few 
things like readGDAL() and raster() but got error message 
"53127_20120124074826_13837.hdf' not recognised as a supported file 
format" . I tried to load hdf5 package but while installing it I got 
Warning message:
In getDependencies(pkgs, dependencies, available, lib) :  package 'hdf5' 
is not available (for R version 2.13.2). I saw the discussion on hdf 
file on the list with topic "*What is the latest re: reading HDF files 
with R*".  In the discussion Roger pointed out that building gdal 
against hdf format might help but I do not have a clue how to do that.
let me know if you want more info from my end.


Regards,

Vikram.

On 1/26/2012 10:01 AM, Paul Hiemstra wrote:
> On 01/26/2012 08:53 AM, Vikram Ranga wrote:
>> Hello List,
>> I was trying to open HDF format files.
>> Though I have followed the discussion on HDF5 format but really cant
>> figure out as I tried to convert HDF to Geotiff but the tool is not
>> working on my system. As the package is not for windows my options are
>> very limited. Can anyone suggest me on this?
>>
>>
>> Regards,
>>
>> Vikram.
>>
>> _______________________________________________
>> R-sig-Geo mailing list
>> R-sig-Geo@r-project.org
>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
> Hi Vikram,
>
> You e-mail is much too vague to yield a good answer. A few questions
> come to mind:
>
> - What is the structure of your HDF files
> - What "discussion on hdf5 format" do you mean? And where can we find
> it? It is best to give a summary in your mail what you took out of this
> discussion.
> - Show us concretely what you did (code, package etc). What R code
> failed to load your HDF file, what was the error message it yielded?
> - What version of R are you using, which package are you using to read
> the HDF file, what are the versions of those packages. This can be
> easily provided using the sessionInfo() command.
>
> Give us more to work with, or it will be very hard to help you.
>
> regards,
> Paul
>

    [[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
R-sig-Geo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo


	[[alternative HTML version deleted]]

