AnsweredAssumed Answered

Rounding the Service Pixel Value in a PopupTemplate

Question asked by Gianna.Gandossi_BBSRC on Aug 6, 2020
Latest reply on Aug 26, 2020 by Gianna.Gandossi_BBSRC

Hello,

 

I have an 32 bit Float single-band ImageryLayer with a popupTemplate assigned.

 

The popup shows the raster service pixel value with the following code:

const variableLayer = new ImageryLayer({
       url: 'https://this_is_a_fake_url/ImageServer',
       popupTemplate: {
            title: '{Raster.ServicePixelValue} variable count(s) in {Year}'
            content: [],
       },
});

 

Is there a way to round the service pixel value which is displayed in the popup? Note: I do not want to round the raster data pixels themselves.

 

I've tried something like this: 

const variableLayer = new ImageryLayer({
       url: 'https://this_is_a_fake_url/ImageServer',
       popupTemplate: {
            //title: '{Raster.ServicePixelValue} variable count(s) in {Year}'
            content: '{expression/pixelvalue} variable count(s) in {Year}',
            expressionInfos: [{
                    name: 'pixelvalue',
                    expression: 'Round($Raster.ServicePixelValue, 2)'
            }]
       },
});

 

Any combination of experimenting that I've tried has resulted in either undefined or null in the place where the pixel value should be displayed in the popup.

 

Any help is massively appreciated! Thank you for reading.

Outcomes