Main Content

matlab.io.hdfeos.gd.getPixels

Namespace: matlab.io.hdfeos.gd

Pixel rows and columns for latitude/longitude pairs

Syntax

[row,col] = getPixels(gridID,lat,lon)

Description

[row,col] = getPixels(gridID,lat,lon) converts latitude/longitude pairs into zero-based pixel row and column coordinates. The origin is the upper left-hand corner of the grid pixel. If the latitude/longitude pairs are outside the grid, then row and col are -1.

This function corresponds to the GDgetpixels function in the HDF-EOS library C API.

Examples

import matlab.io.hdfeos.*
gfid = gd.open('grid.hdf','read');
gridID = gd.attach(gfid,'PolarGrid');
cornerlat = [20 50];
cornerlon = [-90 -60];
[row,col] = gd.getPixels(gridID,cornerlat,cornerlon);
gd.detach(gridID);
gd.close(gfid);