[R-sig-Geo] Problem reading a HDF5 file with readGDAL in Windows

Robert J. Hijmans r.hijmans at gmail.com
Wed May 6 00:07:23 CEST 2015


Yes, you need the ncdf4 package (apart from build your own options
that I would not generally recommend). That's why I explicitly did
`library(ncdf4)`. On windows that indeed means downloading it from
http://cirrus.ucsd.edu/~pierce/ncdf/ and unzipping the content to the
right folder ("install from local zip file" in Rgui). Just a tiny bit
of additional effort.

Robert

On Tue, May 5, 2015 at 2:20 PM, Michael Sumner <mdsumner at gmail.com> wrote:
>
>
> On Wed, 6 May 2015 at 03:28 Robert J. Hijmans <r.hijmans at gmail.com> wrote:
>>
>> Even better (renaming not necessary):
>>
>> x <-
>> raster("E:/downloads/OMI.L2.CloudOMCLDO2Strip200kmAlongCloudSat.2015.05.05.020752Z.v003.he5",
>> var='Data Fields/ChiSquaredOfFit', ncdf=TRUE)
>>
>> Best, Robert
>
>
>
> But only if you build and install ncdf4 yourself (or use DP's one off-CRAN:
> http://cirrus.ucsd.edu/~pierce/ncdf/)
>
> There's no ncdf4 for Windows on CRAN.
>
> Robert's solution doesn't work for me on Windows with ncdf (though I am sure
> it it would if I build ncdf with NetCDF4).
>
> (I feel like I've missed something here . . .)
>
> Cheers, Mike.
>
>>
>>
>> On Tue, May 5, 2015 at 10:24 AM, Robert J. Hijmans <r.hijmans at gmail.com>
>> wrote:
>> > In which case you can change the extension to '.nc' and do
>> >
>> > library(raster)
>> > library(ncdf4)
>> > x <-
>> > raster("E:/downloads/OMI.L2.CloudOMCLDO2Strip200kmAlongCloudSat.2015.05.05.020752Z.v003.nc",
>> > var='Data Fields/ChiSquaredOfFit')
>> >
>> > Robert
>> >
>> > On Tue, May 5, 2015 at 5:28 AM, John Baumgartner <johnbaums at gmail.com>
>> > wrote:
>> >> Not a remedy, but the following might be a workable alternative...
>> >>
>> >>
>> >> ncdf4::nc_open("OMI.L2.CloudOMCLDO2Strip200kmAlongCloudSat.2015.05.05.020752Z.v003.he5")$var$`Data
>> >> Fields/ChiSquaredOfFit`
>> >>
>> >> I'm not familiar with HDF5 structure, so not sure of possible
>> >> downsides.
>> >>
>> >> Cheers,
>> >> John
>> >>
>> >> On Tue, May 5, 2015 at 9:34 PM, Oscar Perpiñan
>> >> <oscar.perpinan at gmail.com>
>> >> wrote:
>> >>
>> >>> Hello,
>> >>>
>> >>> I am trying to read a HDF5 file whose variable name contains '//'. I
>> >>> have
>> >>> no
>> >>> problem in a Linux machine, but 'readGDAL' throws an error in Windows.
>> >>> If I
>> >>> am not wrong, it is because the initialize method of the
>> >>> 'GDALReadOnlyDataset'
>> >>> class includes a call to 'normalizePath'.
>> >>>
>> >>> For example, the next code works in Linux but fails in Windows (it
>> >>> uses
>> >>> this
>> >>> file
>> >>>
>> >>>
>> >>> ftp://atrain.sci.gsfc.nasa.gov/data/s4pa//OMI/OMCLDO2_CPR.003/2015/125/OMI.L2.CloudOMCLDO2Strip200kmAlongCloudSat.2015.05.05.020752Z.v003.he5
>> >>> )
>> >>>
>> >>> x <- readGDAL("HDF5:OMI.L2.CloudOMCLDO2Strip200kmAlongClo
>> >>> udSat.2015.05.05.020752Z.v003.he5://HDFEOS/SWATHS/
>> >>> CloudFractionAndPressure/Data_Fields/ChiSquaredOfFit")
>> >>>
>> >>> Is there any way to circumvent this problem?
>> >>>
>> >>> Thanks in advance.
>> >>>
>> >>> Oscar.
>> >>> -----------------------------------------------------------------
>> >>> Oscar Perpiñán Lamigueiro
>> >>> Dpto. Ing. Eléctrica, Electrónica, Automática y Física Aplicada
>> >>> (ETSIDI-UPM)
>> >>> Grupo de Sistemas Fotovoltaicos (IES-UPM)
>> >>> URL: http://oscarperpinan.github.io
>> >>>
>> >>>         [[alternative HTML version deleted]]
>> >>>
>> >>> _______________________________________________
>> >>> R-sig-Geo mailing list
>> >>> R-sig-Geo at r-project.org
>> >>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>> >>>
>> >>
>> >>         [[alternative HTML version deleted]]
>> >>
>> >> _______________________________________________
>> >> R-sig-Geo mailing list
>> >> R-sig-Geo at r-project.org
>> >> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>>
>> _______________________________________________
>> R-sig-Geo mailing list
>> R-sig-Geo at r-project.org
>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo



More information about the R-sig-Geo mailing list