Skip to content

MODIS Sinusoidal Grid

Juan Emmanuel Johnson edited this page Mar 10, 2024 · 2 revisions

This MODIS data uses a sinusoidal grid which stores the files using a naming convention. More information can be found here. We can use this to define a bounding box using the standard lat/lon coordinates.


Sample Code

def get_modland_grids(min_lon, max_lon, min_lat, max_lat):
    # Define function to convert lon/lat to sinusoidal x/y coordinates
    def lon_lat_to_xy(lon, lat):
        r = 6371007.181
        x = r * np.radians(lon) * np.cos(np.radians(lat))
        y = r * np.radians(lat)
        return x, y

    # Convert bbox to sinusoidal x/y coordinates
    min_x, min_y = lon_lat_to_xy(min_lon, min_lat)
    max_x, max_y = lon_lat_to_xy(max_lon, max_lat)

    # Determine range of grid indices that intersect with bbox
    ntile_vert = 18
    ntile_horiz = 36
    iv_min = math.floor((90.0 + min_y) / 10.0)
    iv_max = math.floor((90.0 + max_y) / 10.0)
    ih_min = math.floor((180.0 + min_x) / 10.0)
    ih_max = math.floor((180.0 + max_x) / 10.0)

    # Loop through grid cells that intersect with bbox and add to list
    grids = []
    for iv in range(iv_min, iv_max + 1):
        for ih in range(ih_min, ih_max + 1):
            grids.append(f'h{iv:02d}v{ih:02d}')

    return grids