I have some MODIS images downloaded. When I try to create a SpatRaster from the hdf files, using terra rast function, it works perfectly for "MOD09A1" but it doesn´t work for "MOD09GA".
terra::rast("C:/Users/User/AppData/Local/Temp/_modis/MOD09GA.A2011025.h08v06.006.2015216102410.hdf")
Error: [rast] number of rows and/or columns do not match
What is the problem? Is there any other function I could use? Thanks!
The problem is that the file has subdatasets with different resolutions.
To get the file your are using
To see the subdatasets:
So you need to access the different subdatasets seperately, like this
Perhaps followed by
Or create a SpatDataSet like this
In the development version of
terra
you can then proceed and door something like the below to get a particular set of subdatasets (that have the same spatial resolution)