worldToDiscrete

Transform planar world to discrete coordinates

Syntax

[I,J] = worldToDiscrete(R,xWorld,yWorld)

Description

[I,J] = worldToDiscrete(R,xWorld,yWorld) returns the indices corresponding to world coordinates xWorld and yWorld in map 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

Map raster, specified as a MapCellsReference or MapPostingsReference object.

x-coordinates in the world coordinate system, specified as a numeric array.

Data Types: single | double

y-coordinates in the world coordinate system, specified as a numeric array. yWorld is the same size as xWorld.

Data Types: single | double

Output Arguments

collapse all

World x-coordinate indices, returned as an array of integers. I is the same size as xWorld.

For an m-by-n raster, 1 ≤ Im, except for points (xWorld(k), yWorld(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

World y-coordinate indices, returned as an array of integers. J is the same size as yWorld.

For an m-by-n raster, 1 ≤ Im, except for points (xWorld(k), yWorld(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