3

I need to know latitude / longitude of each pixel in a MODIS tile image in HDF in order to reproject from sinusoidal (MODIS) to mercator (Google Maps). I Can read values from HDF in my C++ program, I can reproject with proj4 having latitude / longitude of a point. I found a MODLAND Tile calculator with source code in c++ but it have too many dependences in Linux libraries and I'm programming a Windows aplication. Any suggestion will be appreciated

1 Answer 1

3

The answer depends on whether you're working with a gridded MODIS product or a swath product (such as L1B)?

Gridded: MODIS data products use a sinusoidal grid. As described on the LPDAAC MODIS overview page, the metadata in the HDF file contain information about the projection parameters and upper/left lower/right corner coordinates of the tile you are looking at. I don't use C++ but Python, but the libraries you need are originally C++ anyway (GEOS/OSR and GDAL, Proj4). You can easily set up a coordinate transform. In Python:

from pyproj import Proj

p_modis_grid = Proj('+proj=sinu +R=6371007.181 +nadgrids=@null +wktext')
x, y = p_modis_grid(lon, lat)
# or the inverse, from x, y to lon, lat
lon, lat = p_modis_grid(x, y, inverse=True)

Swath: In case you're using L1B swath products, you get an additional geolocation file (MOD3... or MYD3...) that contains lat/lon in WGS84 for each 1km (at nadir) raster point. If you want the 500m or 250m resolution you may have to interpolate.

3
  • In the above code, where should one put the x and y coordinates for tile corners? @chryss
    – MNK
    Commented Jun 21, 2019 at 0:39
  • 1
    @NeeravKaushal - you don't need those if you work with a global projection (or rather, CRS).
    – chryss
    Commented Jun 26, 2019 at 20:51
  • Got it. Thanks @chryss
    – MNK
    Commented Jun 26, 2019 at 20:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.