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

Possible error during unpacking of MOD13Q1 hdf files? #46

Closed
calvus17 opened this issue Apr 12, 2018 · 6 comments
Closed

Possible error during unpacking of MOD13Q1 hdf files? #46

calvus17 opened this issue Apr 12, 2018 · 6 comments
Labels

Comments

@calvus17
Copy link

I have just updated to the new version 1.1.2 of the package and downloaded with runGdal MOD13Q1 hdf files (e.g. MOD13Q1.A2018081.h19v04.006.2018097234738.hdf). The hdf seems to be OK, but the unpacked NDVI layer is strange, the dimension and resolution differs from the images created by the previous version of the package. What could be the problem?
Thanks for helping!

The modis package extracted version of NDVI looks like this:

class : RasterLayer
dimensions : 4800, 7249, 34795200 (nrow, ncol, ncell)
resolution : 231.6418, 231.6564 (x, y)
extent : 933039.2, 2612211, 4447802, 5559753 (xmin, xmax, ymin, ymax)
coord. ref. : +proj=sinu +lon_0=0 +x_0=0 +y_0=0 +a=6371007.181 +b=6371007.181 +units=m +no_defs
data source : /home/norbi/Documents/MODIS/Monitoring/Kicsomagolt_raszterek/MODIS/MOD13Q1.A2018081.250m_16_days_NDVI.tif
names : MOD13Q1.A2018081.250m_16_days_NDVI
values : -32768, 32767 (min, max)

The manually extracted version of NDVI band in R:

class : RasterLayer
dimensions : 4800, 4800, 23040000 (nrow, ncol, ncell)
resolution : 231.6564, 231.6564 (x, y)
extent : 1111951, 2223901, 4447802, 5559753 (xmin, xmax, ymin, ymax)
coord. ref. : +proj=sinu +lon_0=0 +x_0=0 +y_0=0 +a=6371007.181 +b=6371007.181 +units=m +no_defs
data source : /home/norbi/Documents/MODIS/Monitoring/Letoltott_HDF/MOD13Q1.A2018081.h19v04.006.2018097234738 NDVI .tif
names : MOD13Q1.A2018081.h19v04.006.2018097234738_NDVI_
values : -32768, 32767 (min, max)

fdetsch added a commit that referenced this issue Jul 10, 2018
fdetsch added a commit that referenced this issue Jul 11, 2018
…input MODIS Sinusoidal grid when using Extent (raster) or bbox objects (sf) as 'extent'.
@fdetsch
Copy link
Owner

fdetsch commented Jul 11, 2018

Awesome, thanks for reporting – and sorry for the long delay.

Dimensions and resolution issues should be fixed as of 72fac2d when working with 'tileH,tileV':

# devtools::install_github("MatMatt/MODIS", ref = "develop")
library(MODIS)

tfs = runGdal("MOD13Q1", begin = "2018081", end = "2018081"
              , tileH = 19, tileV = 4, SDSstring = "100000000000", job = "tmp"
              , overwrite = TRUE, outProj = "asIn")

rst = raster(unlist(tfs))
rst
# class       : RasterLayer 
# dimensions  : 4800, 4800, 23040000  (nrow, ncol, ncell)
# resolution  : 231.6564, 231.6564  (x, y)
# extent      : 1111951, 2223901, 4447802, 5559753  (xmin, xmax, ymin, ymax)
# coord. ref. : +proj=sinu +lon_0=0 +x_0=0 +y_0=0 +a=6371007.181 +b=6371007.181 +units=m +no_defs 
# data source : C:\...\MODIS_ARC\PROCESSED\tmp\MOD13Q1.A2018081.250m_16_days_NDVI.tif 
# names       : MOD13Q1.A2018081.250m_16_days_NDVI 
# values      : -32768, 32767  (min, max)

Moreover as of 0ab9a66, this also works for spatial subsets defined as Extent or bbox objects from raster and sf, respectively.

library(sf)
library(mapview)

tfs_ext = runGdal("MOD13Q1", begin = "2018081", end = "2018081"
              , extent = st_bbox(franconia), SDSstring = "100000000000", job = "tmp2"
              , overwrite = TRUE, outProj = "asIn")

rst_ext = raster(unlist(tfs_ext))
rst_ext
# class       : RasterLayer 
# dimensions  : 817, 1141, 932197  (nrow, ncol, ncell)
# resolution  : 231.6564, 231.6564  (x, y)
# extent      : 633811.8, 898131.7, 5433268, 5622531  (xmin, xmax, ymin, ymax)
# coord. ref. : +proj=sinu +lon_0=0 +x_0=0 +y_0=0 +a=6371007.181 +b=6371007.181 +units=m +no_defs 
# data source : C:\...\MODIS_ARC\PROCESSED\tmp2\MOD13Q1.A2018081.250m_16_days_NDVI.tif 
# names       : MOD13Q1.A2018081.250m_16_days_NDVI 
# values      : -32768, 32767  (min, max)

@calvus17 you're working on a Linux OS, right? Could you please test the above code?

@fdetsch fdetsch added the bug label Jul 11, 2018
@calvus17
Copy link
Author

Thank you for your reply!
I tried the above code but unfortunately I got the same results as before. The x coordinate deviate from the y, latter seems to be good. I will try it later on an other computer. I use R studio Version 1.1.442 with R 3.4.4.
Kind regards,
Norbert

tfs = runGdal("MOD13Q1", begin = "2018081", end = "2018081"

  •           , tileH = 19, tileV = 4, SDSstring = "100000000000", job = "tmp"
    
  •           , overwrite = TRUE, outProj = "asIn")
    

No collection specified, getting the newest for MOD13Q1
########################
outProj = asIn
pixelSize = asIn
resamplingType = near
Output Directory = /home/norbi/Documents/MODIS/Monitoring/Kicsomagolt_raszterek/tmp
########################
Local structure is up-to-date. Using offline information!
Creating output file that is 7249P x 4800L.
Processing input file HDF4_EOS:EOS_GRID:/home/norbi/Documents/MODIS/Monitoring/Letoltott_HDF/MODIS/MOD13Q1.006/2018.03.22/MOD13Q1.A2018081.h19v04.006.2018097234738.hdf:MODIS_Grid_16DAY_250m_500m_VI:250m 16 days NDVI.
0...10...20...30...40...50...60...70...80...90...100 - done.

rst = raster(unlist(tfs))
rst
class : RasterLayer
dimensions : 4800, 7249, 34795200 (nrow, ncol, ncell)
resolution : 231.6418, 231.6564 (x, y)
extent : 933039.2, 2612211, 4447802, 5559753 (xmin, xmax, ymin, ymax)
coord. ref. : +proj=sinu +lon_0=0 +x_0=0 +y_0=0 +a=6371007.181 +b=6371007.181 +units=m +no_defs
data source : /home/norbi/Documents/MODIS/Monitoring/Kicsomagolt_raszterek/tmp/MOD13Q1.A2018081.250m_16_days_NDVI.tif
names : MOD13Q1.A2018081.250m_16_days_NDVI
values : -32768, 32767 (min, max)

@fdetsch
Copy link
Owner

fdetsch commented Jul 12, 2018

Hm, I cannot reproduce that...

But you did install the MODIS 'develop' version before running the code (see first commented line in my first code chunk), right? In addition, what's your output of sessionInfo().

@calvus17
Copy link
Author

OK, I missed that line, it works now perfectly!
Thanks a lot!

@fdetsch
Copy link
Owner

fdetsch commented Jul 12, 2018

Great, glad it finally works. Again, thanks for notifying - it's really important that we fixed this!

@fdetsch fdetsch closed this as completed Jul 12, 2018
@calvus17
Copy link
Author

calvus17 commented Jul 16, 2020 via email

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

No branches or pull requests

2 participants