Skip to content

Error reading hdf files with rgdal

8 messages · Kelly McCaffrey, Roger Bivand, Michael Sumner +1 more

#
Hello all,
I'm working with some .hdf files containing MODIS satellite data, but I
have been unable to read them into R using rgdal and gdalUtils since the
last rgdal update. Has anyone else experienced these issues and does anyone
have a suggested fix? The code I'm attempting to use and error message are
as follows:

library(raster)
library(rgdal)
library(gdalUtils)
file<-"MODWCW_2017010_DAILY_AQUA_CHLORA_EC_1KM.hdf"
sds<-get_subdatasets(file)
Error in split1[[1]] : subscript out of bounds

I've tried this code with .hdf files from different sources, and they
return the same error. I've attempted to download and use an older version
of rgdal as a workaround, but I am having trouble obtaining its software
dependencies and would prefer a fix compatible with the current version of
the package.
Thanks!
Kelly
#
Please provide the output of the startup messages from the loaded packages, and of sessionInfo().

Roger Bivand
Norwegian School of Economics
Bergen, Norway

Fra: Kelly McCaffrey
Sendt: fredag 13. januar, 20.51
Emne: [R-sig-Geo] Error reading hdf files with rgdal
Til: R-sig-geo mailing list

Hello all, I'm working with some .hdf files containing MODIS satellite data, but I have been unable to read them into R using rgdal and gdalUtils since the last rgdal update. Has anyone else experienced these issues and does anyone have a suggested fix? The code I'm attempting to use and error message are as follows: library(raster) library(rgdal) library(gdalUtils) file
#
Here are the startup messages and the sessionInfo() output:
Loading required package: sp
rgdal: version: 1.2-5, (SVN revision 648)
 Geospatial Data Abstraction Library extensions to R successfully loaded
 Loaded GDAL runtime: GDAL 2.0.1, released 2015/09/15
 Path to GDAL shared files:
C:/Users/kmccaffrey2011/Documents/R/win-library/3.3/rgdal/gdal
 Loaded PROJ.4 runtime: Rel. 4.9.2, 08 September 2015, [PJ_VERSION: 492]
 Path to PROJ.4 shared files:
C:/Users/kmccaffrey2011/Documents/R/win-library/3.3/rgdal/proj
 Linking to sp version: 1.2-4
R version 3.3.2 (2016-10-31)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)

locale:
[1] LC_COLLATE=English_United States.1252
[2] LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C
[5] LC_TIME=English_United States.1252

attached base packages:
[1] stats     graphics  grDevices utils
[5] datasets  methods   base

other attached packages:
[1] gdalUtils_2.0.1.7 rgdal_1.2-5
[3] raster_2.5-8      sp_1.2-4

loaded via a namespace (and not attached):
 [1] tools_3.3.2       Rcpp_0.12.8
 [3] R.methodsS3_1.7.1 codetools_0.2-15
 [5] grid_3.3.2        iterators_1.0.8
 [7] foreach_1.4.3     R.utils_2.5.0
 [9] R.oo_1.21.0       lattice_0.20-34


Kelly
On Fri, Jan 13, 2017 at 3:06 PM, Roger Bivand <Roger.Bivand at nhh.no> wrote:

            

  
    
#
Try listing the subdatasets and reading them directly with GDAL or readGDAL

On Sat, Jan 14, 2017, 07:12 Kelly McCaffrey <kmccaffrey2011 at my.fit.edu>
wrote:
1 day later
#
Using GDAL and readGDAL both result in the error message:
Error in .local(.Object, ...) :
With no other message following this warning. Trying to use GDALinfo()
results in the same warning. I'm having these problems trying to use .hdf
files I have previously successfully accessed and transformed to geoTIFF
files as well.
On Fri, Jan 13, 2017 at 7:18 PM, Michael Sumner <mdsumner at gmail.com> wrote:

            

  
    
#
When you see an error message from the R interpreter, include the full output, and the output of traceback() issued immediately after the error. Nothing important in raster handling has changed in rgdal. Try to provide a reprodicible example that you can show succeeded on the same system with earlier versions of packages, and which now fail. We cannot see over your shoulder.

Roger Bivand
Norwegian School of Economics
Bergen, Norway
On Sun, Jan 15, 2017 at 7:17 PM +0100, "Kelly McCaffrey" <kmccaffrey2011 at my.fit.edu<mailto:kmccaffrey2011 at my.fit.edu>> wrote:
Using GDAL and readGDAL both result in the error message:
Error in .local(.Object, ...) :
With no other message following this warning. Trying to use GDALinfo() results in the same warning. I'm having these problems trying to use .hdf files I have previously successfully accessed and transformed to geoTIFF files as well.
On Fri, Jan 13, 2017 at 7:18 PM, Michael Sumner <mdsumner at gmail.com<mailto:mdsumner at gmail.com>> wrote:
Try listing the subdatasets and reading them directly with GDAL or readGDAL
On Sat, Jan 14, 2017, 07:12 Kelly McCaffrey <kmccaffrey2011 at my.fit.edu<mailto:kmccaffrey2011 at my.fit.edu>> wrote:
Here are the startup messages and the sessionInfo() output:
Loading required package: sp
rgdal: version: 1.2-5, (SVN revision 648)
 Geospatial Data Abstraction Library extensions to R successfully loaded
 Loaded GDAL runtime: GDAL 2.0.1, released 2015/09/15
 Path to GDAL shared files:
C:/Users/kmccaffrey2011/Documents/R/win-library/3.3/rgdal/gdal
 Loaded PROJ.4 runtime: Rel. 4.9.2, 08 September 2015, [PJ_VERSION: 492]
 Path to PROJ.4 shared files:
C:/Users/kmccaffrey2011/Documents/R/win-library/3.3/rgdal/proj
 Linking to sp version: 1.2-4
R version 3.3.2 (2016-10-31)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)

locale:
[1] LC_COLLATE=English_United States.1252
[2] LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C
[5] LC_TIME=English_United States.1252

attached base packages:
[1] stats     graphics  grDevices utils
[5] datasets  methods   base

other attached packages:
[1] gdalUtils_2.0.1.7 rgdal_1.2-5
[3] raster_2.5-8      sp_1.2-4

loaded via a namespace (and not attached):
 [1] tools_3.3.2       Rcpp_0.12.8
 [3] R.methodsS3_1.7.1 codetools_0.2-15
 [5] grid_3.3.2        iterators_1.0.8
 [7] foreach_1.4.3     R.utils_2.5.0
 [9] R.oo_1.21.0       lattice_0.20-34


Kelly
On Fri, Jan 13, 2017 at 3:06 PM, Roger Bivand <Roger.Bivand at nhh.no<mailto:Roger.Bivand at nhh.no>> wrote:

            
--

*Kelly McCaffrey*
Graduate Student
Department of Biological Sciences
Florida Institute of Technology
150 W. University Blvd.
Melbourne, FL, 32901


_______________________________________________
R-sig-Geo mailing list
R-sig-Geo at r-project.org<mailto:R-sig-Geo at r-project.org>
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
--
Dr. Michael Sumner
Software and Database Engineer
Australian Antarctic Division
203 Channel Highway
Kingston Tasmania 7050 Australia




--

Kelly McCaffrey
Graduate Student
Department of Biological Sciences
Florida Institute of Technology
150 W. University Blvd.
Melbourne, FL, 32901
#
Just to cover all the bases, MODIS hdf files require the hdf4 library. If
you changed something with your GDAL install you might not have this
anymore.

at the commandline prompt, gdalinfo --format HDF4 should give the following
Khione:~ $ gdalinfo --format HDF4
Format Details:
  Short Name: HDF4
  Long Name: Hierarchical Data Format Release 4
  Supports: Raster
  Extension: hdf
  Help Topic: frmt_hdf4.html
  Supports: Subdatasets
  Supports: Open() - Open existing dataset.

Dominik
On Sun, Jan 15, 2017 at 7:36 PM, Roger Bivand <Roger.Bivand at nhh.no> wrote:

            

  
  
#
Thank you all! It seems to have been the GDAL installation on my system, as
Dominik suggested.
Best,
Kelly

On Mon, Jan 16, 2017 at 8:18 AM, Dominik Schneider <dosc3612 at colorado.edu>
wrote: