Main Content

geographicToDiscrete

Transform geographic to discrete coordinates

Description

[I,J] = geographicToDiscrete(R,lat,lon) returns the indices corresponding to geographic coordinates lat and lon in geographic raster R. If R.RasterInterpretation is:

  • 'cells', then I and J are the row and column subscripts of the raster cells (or image pixels)

  • 'postings', then I and J refer to the nearest sample point (posting)

Input Arguments

collapse all

Geographic raster, specified as a GeographicCellsReference or GeographicPostingsReference object.

Latitude coordinates, specified as a numeric array.

Data Types: single | double

Longitude coordinates, specified as a numeric array. lon is the same size as lat.

Data Types: single | double

Output Arguments

collapse all

Longitude indices, returned as an array of integers. I is the same size as lat.

For an m-by-n raster, 1 ≤ Im, except for points ( lat(k), lat(k) ) that fall outside the bounds of the raster as defined by the function contains. In this case I(k) and J(k) are NaN.

Data Types: double

Latitude indices, returned as an array of integers. J is the same size as lat.

For an m-by-n raster, 1 ≤ Jnexcept for points ( lat(k), lat(k) ) that fall outside the bounds of the raster as defined by the function contains. In this case I(k) and J(k) are NaN.

Data Types: double

Introduced in R2013b