A set of functions for working with the pixel data type.


Count

Count(inputPixel) -> Number

Since version 1.37

Function bundle: Core

Returns the number of entries in a pixel.

Parameter

  • inputPixel: Pixel - The input pixel.

Return value: Number

Example

Returns the number of entries in the pixel

Use dark colors for code blocksCopy
1
2
Count($pixel)
// returns 6

DefaultValue

DefaultValue(inputPixel, key, defaultValue) -> Any

Since version 1.35

Function bundle: Core

Returns a specified default value if a field name in a given pixel does not exist or the value of the specified field is null or an empty text value.

Parameters

  • inputPixel: Pixel - The input pixel to check.
  • key: Text - The field name to check for a value.
  • defaultValue: Any - This value is returned if the field name does not exist or the value of the specified field is null or an empty text value.

Return value: Any
Returns the value for the specified field if defined. Otherwise, returns the value specified in defaultValue.

Example

Return "No data" if pixel attribute does not exist or is empty

Use dark colors for code blocksCopy
1
2
3
DefaultValue($pixel, "Raster.sea_temp", "No data")
// Returns the sea_temp value if available
// or 'No data' if not available

GetKeys

GetKeys(inputPixel) -> Array<Text>

Since version 1.37

Function bundle: Core

Returns an array of all keys in the pixel, sorted alphabetically.

Parameter

  • inputPixel: Pixel - The pixel to get keys from.

Return value: Array<Text>

Example

Returns an array of keys from the pixel, in alphabetical order.

Use dark colors for code blocksCopy
1
2
GetKeys($pixel)
// returns ["Raster.Dim.StdTime","Raster.Direction", "Raster.Magnitude", "Raster.ServicePixelValue", "Raster.ServicePixelValue.Raw", "Raster.Variable"]

GetValues

GetValues(inputPixel) -> Array<Any>

Since version 1.37

Function bundle: Core

Returns an array of all values in the pixel, ordered to match the alphabetical sorting of their keys.

Parameter

  • inputPixel: Pixel - The pixel to get values from.

Return value: Array<Any>

Example

Returns all values in the pixel

Use dark colors for code blocksCopy
1
2
GetValues($pixel)
// returns ["2011-12-30T19:00:00-05:00",48.96202850341797,1.9298123121261597,["1.9298123121261597","48.96202850341797"],["1.9298123121261597","48.96202850341797"],"wind_magdir"]

HasKey

HasKey(inputPixel, key) -> Boolean

Since version 1.35

Function bundle: Core

Indicates whether a pixel contains the given key or attribute.

Parameters

  • inputPixel: Pixel - The pixel to check for an attribute name.
  • key: Text - The attribute name to check.

Return value: Boolean

Example

Returns true if the pixel has an attribute named elev

Use dark colors for code blocksCopy
1
HasKey($pixel, 'elev');

HasValue

HasValue(inputPixel, key) -> Boolean

Since version 1.35

Function bundle: Core

Indicates whether a pixel has a given attribute and if that attribute has a value.

Parameters

  • inputPixel: Pixel - The pixel to check.
  • key: Text - The attribute name to check for a value.

Return value: Boolean

Additional resources

Example

Return false if pixel attribute does not exist or is empty

Use dark colors for code blocksCopy
1
2
iif(HasValue($pixel, "Raster.ServicePixelValue"), ($pixel["Raster.ServicePixelValue"][0] - 32) * 5/9, "No Data")
// Returns the temp in celsius if the Raster.ServicePixelValue is available

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.