Skip to main content
added 3141 characters in body
Source Link
Micha
  • 15.8k
  • 23
  • 29

If you want to reproject the MODIS datasets in advance then these steps might help: First use gdal_translate to create a VRT (should automatically contain the GCP's). Then gdalwarp to the projection that you want, using the "thin plate spline" option. And finally import into a GRASS Location defined by that same projection. i.e.

gdal_translate -of VRT HDF4_EOS:EOS_SWATH:"MOD02QKM.A2019044.1415.061.2019045012150.hdf":MODIS_SWATH_Type_L1B:EV_250_RefSB eos.vrt
gdalwarp -t_srs EPSG:4326 -tps eos.vrt eos.tif
# Switch to a WGS84 Location, and import
g.mapset location=WGS84 map=PERMANENT
r.in.gdal input=eos.tif output=eos
Importing 2 raster bands...
Importing raster map <eos.1>...
 100%
Importing raster map <eos.2>...
 100%
r.info eos.1
 +----------------------------------------------------------------------------+
 | Map:      eos.1                          Date: Tue Nov  3 20:52:04 2020    |
 | Mapset:   PERMANENT                      Login of Creator: micha           |
 | Location: WGS84                                                            |
 | DataBase: /home/micha/GIS/grass                                            |
 | Title:                                                                     |
 | Timestamp: none                                                            |
 |----------------------------------------------------------------------------|
 |                                                                            |
 |   Type of Map:  raster               Number of Categories: 0               |
 |   Data Type:    CELL                                                       |
 |   Rows:         7278                                                       |
 |   Columns:      9389                                                       |
 |   Total Cells:  68333142                                                   |
 |        Projection: Latitude-Longitude                                      |
 |            N: 12:08:47.681048S    S: 33:12:58.502358S   Res: 0:00:10.42193 |
 |            E: 47:24:22.942618W    W: 74:35:14.462442W   Res: 0:00:10.42193 |
 |   Range of data:    min = 367  max = 65534                                 |
 |                                                                            |
 |   Data Description:                                                        |
 |    generated by r.in.gdal                                                  |
 |                                                                            |
 |   Comments:                                                                |
 |    r.in.gdal input="eos.tif" output="eos" memory=300 offset=0 num_digit\   |
 |    s=0                                                                     |
 |                                                                            |
 +----------------------------------------------------------------------------+

g.mapset location=WGS84 map=PERMANENT

If you want to reproject the MODIS datasets in advance then these steps might help: First use gdal_translate to create a VRT (should automatically contain the GCP's). Then gdalwarp to the projection that you want, using the "thin plate spline" option. And finally import into a GRASS Location defined by that same projection. i.e.

gdal_translate -of VRT HDF4_EOS:EOS_SWATH:"MOD02QKM.A2019044.1415.061.2019045012150.hdf":MODIS_SWATH_Type_L1B:EV_250_RefSB eos.vrt
gdalwarp -t_srs EPSG:4326 -tps eos.vrt eos.tif
# Switch to a WGS84 Location, and import
g.mapset location=WGS84 map=PERMANENT
r.in.gdal input=eos.tif output=eos
Importing 2 raster bands...
Importing raster map <eos.1>...
 100%
Importing raster map <eos.2>...
 100%
r.info eos.1
 +----------------------------------------------------------------------------+
 | Map:      eos.1                          Date: Tue Nov  3 20:52:04 2020    |
 | Mapset:   PERMANENT                      Login of Creator: micha           |
 | Location: WGS84                                                            |
 | DataBase: /home/micha/GIS/grass                                            |
 | Title:                                                                     |
 | Timestamp: none                                                            |
 |----------------------------------------------------------------------------|
 |                                                                            |
 |   Type of Map:  raster               Number of Categories: 0               |
 |   Data Type:    CELL                                                       |
 |   Rows:         7278                                                       |
 |   Columns:      9389                                                       |
 |   Total Cells:  68333142                                                   |
 |        Projection: Latitude-Longitude                                      |
 |            N: 12:08:47.681048S    S: 33:12:58.502358S   Res: 0:00:10.42193 |
 |            E: 47:24:22.942618W    W: 74:35:14.462442W   Res: 0:00:10.42193 |
 |   Range of data:    min = 367  max = 65534                                 |
 |                                                                            |
 |   Data Description:                                                        |
 |    generated by r.in.gdal                                                  |
 |                                                                            |
 |   Comments:                                                                |
 |    r.in.gdal input="eos.tif" output="eos" memory=300 offset=0 num_digit\   |
 |    s=0                                                                     |
 |                                                                            |
 +----------------------------------------------------------------------------+

g.mapset location=WGS84 map=PERMANENT
Source Link
Micha
  • 15.8k
  • 23
  • 29

Just to summarize from the comments:

gdalinfo shows the different HDF datasets as

Subdatasets:
  SUBDATASET_1_NAME=HDF4_EOS:EOS_SWATH:"MOD02QKM.A2019044.1415.061.2019045012150.hdf":MODIS_SWATH_Type_L1B:EV_250_RefSB
  SUBDATASET_1_DESC=[2x8120x5416] EV_250_RefSB MODIS_SWATH_Type_L1B (16-bit unsigned integer)
  SUBDATASET_2_NAME=HDF4_EOS:EOS_SWATH:"MOD02QKM.A2019044.1415.061.2019045012150.hdf":MODIS_SWATH_Type_L1B:EV_250_RefSB_Uncert_Indexes
  SUBDATASET_2_DESC=[2x8120x5416] EV_250_RefSB_Uncert_Indexes MODIS_SWATH_Type_L1B (8-bit unsigned integer)
  SUBDATASET_3_NAME=HDF4_SDS:UNKNOWN:"MOD02QKM.A2019044.1415.061.2019045012150.hdf":0
  SUBDATASET_3_DESC=[2030x1354] Latitude (32-bit floating-point)
  SUBDATASET_4_NAME=HDF4_SDS:UNKNOWN:"MOD02QKM.A2019044.1415.061.2019045012150.hdf":1
.....

Then you can import a single dataset into an unprojected XY Location with the command:

GRASS 7.8.4 (XY):~/work/tmp > r.in.gdal input=HDF4_SDS:UNKNOWN:"MOD02QKM.A2019044.1415.061.2019045012150.hdf":1 output=sds1
No projection information available
Importing raster map <sds1>...
 100%