MI_GridValueAtPixel
Description
Returns the value of a Grid at the specified pixel location (x, y). This function also applies to MRR file and all field types are supported.
Syntax
Arguments
MI_GridValueAtPixel has the following arguments:
- GridInfo identifies the information from the Raster or Grid file. The value is always the string MI_RASTER.
- XPixel is an expression which returns an integer representing the X pixel coordinate.
- YPixel is an expression which returns an integer representing the Y pixel coordinate.
- field specifies the field index and is an integer value greater than or equal to zero (0). It is an optional parameter. See the example of a DescribeTable rest call for more clarity on the valid field value.
- band specifies the band index of the field selected and is an integer value greater than or equal to zero (0). It is required only if the field is specified. See the example of a DescribeTable rest call for more clarity on the valid field value.
Example
Determines the grid value of the MI_RASTER column at the x=10, y=10 pixel from the table named GRIDTABLE.
select MI_GridValueAtPixel("MI_RASTER", 10, 10, 1, 0) from "/GRIDTABLE"
Remarks
Raster tables expose a RasterInfo and grid tables expose a GridInfo as the value for the MI_Raster column. This function applies to grid images (.GRD, .GRC, and .MRR).
For grid types other than MRR, such as GRD, do not include field and band parameters or specify zero (0) for their values.
For example, following is a valid example for a GRD file:
select MI_GridValueAtPixel("MI_RASTER", MI_POINT(445185.0, 5029793.0, 'EPSG:26918')) from "/testdata/grdtable"
The following example will fail when both field and band are set to zero (0)
select MI_GridValueAtPixel("MI_RASTER", MI_POINT(445185.0, 5029793.0, 'EPSG:26918'), 0, 0) from "/testdata/grdtable"
The following will fail for an earlier grid because the field is set to one (1):
select MI_GridValueAtPixel("MI_RASTER", MI_POINT(445185.0, 5029793.0, 'EPSG:26918'), 1, 0) from "/testdata/grdtable"
The following will work for a MRR if MRR has more than one field, and appropriate field, band values are passed:
select MI_GridValueAtPixel("MI_RASTER", MI_POINT(445185.0, 5029793.0, 'EPSG:26918'), 1, 0) from "/testdata/mrrtable"
The band and field value precedence rules for MRR
- When field and band values are there in the GHX as well as in the query, the field and band values of the query are considered
- When field and band values are there in the GHX, and the query has no field and band values at all, the band and field values of the GHX are considered
- When the GHX is not present at all, the field and band values of the query are considered
- When GHX is not present at all and no values have been passed in the query, default values of 0,0 will be considered for field and band respectively