MATLAB Examples

grainsize_interp documentation

grainsize_interp returns MODIS MOA grain sizes interpolated to any Antarctic locations(s).


Dataset documentation:

Find full documentation for this dataset at the NSIDC website here.

Citing this dataset: If you use grain size data, please cite both of the following:

Haran, T., J. Bohlander, T. Scambos, T. Painter, and M. Fahnestock. 2014. MODIS Mosaic of Antarctica 2008-2009 (MOA2009) Image Map. MOA grain size image map. Boulder, Colorado USA: National Snow and Ice Data Center.

Scambos, T., T. Haran, M. Fahnestock, T. Painter, and J. Bohlander. 2007. MODIS-based Mosaic of Antarctica (MOA) data sets: Continent-wide Surface Morphology and Snow Grain Size. Remote Sensing of Environment 111(2): 242-257.


This function requires Antarctic Mapping Tools for Matlab ( If the function cannot find moa125_2009_grn_v1.1.tif, it will ask if you want to try to automatically download it. Be warned, it's a 4 GB dataset, so it will take a few minutes to download. If you prefer to download the data manually, get it here: After downloading the data, unzip it and make sure Matlab can find it, either by navigating to the folder or by adding a path to the directory where you keep your downloaded data and functions.


grainsize = grainsize_interp(lati,loni)
grainsize = grainsize_interp(xi,yi)


grainsize = grainsize_interp(lati,loni) returns surface grain size(s) in microns at the geo coordinates lati,loni. Interpolation is nearest-neighbor to the 125 m underlying MOA grain size dataset. Values of 5 and 1105 represent grain size values outside the optical range 10 through 1100, for example some blue ice areas or data for which grain size could not be computed.

grainsize = grainsize_interp(xi,yi) returns values at the polar stereographic (meters, true lat 71 S) coordinates xi,yi. Coordinates are automatically determined by the islatlon function.

Geocoordinate example

For a 500 km wide grid centered on Taylor Glacier, at 0.5 km resolution, get a grain size map:

[lat,lon] = psgrid('taylor glacier',500,0.5);
g = grainsize_interp(lat,lon);

If you have Matlab's Mapping Toolbox, grain size can be plotted like this:

mapzoom('taylor glacier')
cb = colorbar
ylabel(cb,'grain size (microns)')
cb =

Polar stereographic coordinate example

If you don't have Matlab's Mapping Toolbox, you can still use this function and plot data. Similar to the example above, start by making a grid. The grid can be in geo coordinates or polar stereographic meters. Here we'll use polar stereographic meters by specifying 'xy' when we call psgrid and we'll make an 800-km wide map surrounding the Antarctic Peninsula at 1 km resolution:

[x,y] = psgrid('antarctic peninsula',800,1,'xy');
G = grainsize_interp(x,y);

Now plot and place an inset map in the upper right corner ('northeast' or 'ne') of the map. There are a few ways to make this plot. The simplest way is to use pcolor and follow it with axis image to give equal dimension to northings and eastings and remove any extra unused space in the map. Also with pcolor make sure you specify shading flat or shading interp because otherwise you'll end up with a block of black lines that make up the mesh:

mapzoomps('antarctic peninsula',800,'ne');
shading flat
axis image

The pcolor function works in many cases, but note, if your datset gets large, the imagesc function is usually much faster for large gridded datasets. The syntax for imagesc is slightly different--instead of specifying a grid of coordinates you'll specify arrays of x,y coordinates. The imagesc function also flips the vertical axis so you'll have to set axis xy. Yet another manual step you'll have to take with imagesc regards NaN values, which by default are colored to match the lowest value in the dataset. But you can set transparency with alpha settings:

h = imagesc(x(1,:),y(:,1),G);
axis xy image

Author Info

This function was written by Chad A. Greene of the University of Texas at Austin's Institute for Geophysics (UTIG), March 2016.