swath2grid

Recently I needed to convert swath data to gridded data. Most MODIS products come as gridded products which are properly geo-referenced / rectified. However, some low level products are provided as “swath” data which are the “raw” form when it comes to geo-referencing. Luckily most of these swath products do provide ground control point information to convert them from wobbly sensor output to a gridded geo-referenced image.

This procedure of converting from swath to gridded data is normally done with the MODIS Resampling Tool (MRT) software. Here, I provide a few lines of code which will do just the same using the community driven Geospatial Data Abstraction Library (GDAL). I would argue that the four lines of true code beat installing the MRT tool any day.

The code is a mashup of a stackexchange post and converts MODIS L1B data (or similar) to gridded data, requiring you to specify the file name and the requested scientific data subset (SDS). You can find the available SDS using the gdalinfo command, or using the product information sheet. The data is output as a geotiff.

 

One Reply to “swath2grid”

  1. Hello, I’m using the MOD04 product and another L2 products like MOD06, MOD07 and MOD11. When I try to use your code I have the following error:
    Creating output file that is 467P x -2147483648L.
    ERROR 1: Attempt to create 467x-2147483648 dataset is illegal,sizes must be larger than zero.

    In another case when trying with MOD11 I have the following error:
    gdal_translate -of VRT HDF4_EOS:EOS_SWATH:”MOD11_L2.A2014001.1300.006.2016179212636.hdf”:mod11:LST modis.vrt
    ERROR 4: No such file or directory

    Can you help me with this?
    Best regards.

Leave a Reply

Your email address will not be published. Required fields are marked *