We can import and read all given bands/parameters of MOD10C2, lat and lon is not given as separate band rather embedded with other bands. How we can extract from MOD10C2 hdf data in matlab.

Similar question found here for python

  • 1
    $\begingroup$ I've answered here, but this should be migrated to GIS SE, if you have more questions like this I would recommend you to post them there. $\endgroup$ – Camilo Rada Feb 6 at 15:10
  • $\begingroup$ Initially I just generated the lat lon in a simple way lat = -90:0.05:90; and lon = -180:0.05:180; then subsetted the data with had lead to error (possibly). $\endgroup$ – irfan Feb 7 at 1:42
  • 1
    $\begingroup$ Yes, because those lat/lon have one element more than the real data. Thos would ne 3601x1 and 7201x1 respectively. $\endgroup$ – Camilo Rada Feb 7 at 1:57

The latitude and longitude of each pixel is not stored in the HDF file. But using


You can get the info to generate those latitudes and longitudes. In metadata.Attibutes you will find this among other things:


If you rather a more human-readable format, check the product specifications for MOD10C2.

There it say:


MODIS CMG data sets are produced in a Geographic Lat/Lon projection. This simple projection treats geographical longitude and latitude degrees as if they were x- and y-coordinates in a plane. Figure 1 shows the geographical lat/lon projection known as Plate Carrée, which plots longitude and latitude degrees as coordinates on the x and y axes, respectively:

enter image description here

Figure 1: Plate Carrée projection.


The MODIS CMG consists of 7200 columns by 3600 rows. Each cell has a resolution of 0.05 degrees (approximately 5 km). The upper-left corner of the upper-left cell is -180.00 degrees longitude, 90.00 degrees latitude. The lower-right corner of the lower right cell is -180.00 degrees longitude, -90.00 degrees latitude...

With that you have more than enough information to generate the latitude and longitude vectors. Now you have to decide if you will store the center of each pixel, or one of the corners.

Assuming you will store the center of each pixel you can generate the latitude and longitude vectors like this:

gridSize=0.05 % arc degrees

And if you want instead matrices with the coordinates of the center of each individual pixel, you do


  • $\begingroup$ Is there a way to get average/mean of whole pixel beside targeting the centre and corner? $\endgroup$ – irfan Feb 7 at 1:45
  • $\begingroup$ What do you mean? The pixel is already the average of snow cover in an area of 0.05x0.05 degrees, and to geolocate it you need its four corners. However, knowing its size you just need to store one corner or the center. $\endgroup$ – Camilo Rada Feb 7 at 2:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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