Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with cleanMODIS(), Cannot create a RasterLayer object from this file. (file does not exist) #57

Open
TimWeatherman opened this issue Jan 15, 2016 · 2 comments

Comments

@TimWeatherman
Copy link

In cleanMODIS.r line 56, the call to raster() is on the subset string rather than the filename that is returned from readGDAL(), like on line 55. This causes an error, file does not exist.

Error in .local(.Object, ...) : 
  `/home/tim/geoscripting/Project/data/HDF4_EOS:EOS_GRID:MCD15A2H.A2002193.h19v03.006.2015149105839.hdf:MOD_Grid_MOD15A2H:FparLai_QC' does not exist in the file system,
and is not recognised as a supported dataset name.


Error in .rasterObjectFromFile(x, band = band, objecttype = "RasterLayer",  : 
  Cannot create a RasterLayer object from this file. (file does not exist)

A reproducible case is:

library(bfastSpatial)
download.file("http://e4ftl01.cr.usgs.gov//MODV6_Cmp_A/MOTA/MCD15A2H.006/2002.07.04/MCD15A2H.A2002185.h19v03.006.2015149105834.hdf", method = "wget", destfile = "MCD15A2H.A2002193.h19v03.006.2015149105839.hdf")

QC <- raster(get_subdatasets("MCD15A2H.A2002193.h19v03.006.2015149105839.hdf")[3])
QC <- raster(readGDAL(get_subdatasets("MCD15A2H.A2002193.h19v03.006.2015149105839.hdf")[3]))

The first line fails, the second line works correctly.

@loicdtx
Copy link
Owner

loicdtx commented Jan 15, 2016

It works if you use full path.

@GreatEmerald
Copy link

Yes, looks like it. It also works if the file is in a subdirectory, like this:

QC <- raster(get_subdatasets("data/MCD15A2H.A2002193.h19v03.006.2015149105839.hdf")[3])

In order to make it work correctly with files in the working directory, this seems to be the solution:

QCG <- raster(get_subdatasets(normalizePath("MCD15A2H.A2002193.h19v03.006.2015149105839.hdf"))[3])

So perhaps https://github.com/dutri001/bfastSpatial/blob/master/R/cleanMODIS.R#L54 should be changed to:

sds <- get_subdatasets(normalizePath(x))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants