Select to view content in your preferred language

Raster identify (pixel value) with viewer for flex

6971
25
11-22-2011 09:39 AM
MartynSmith
Emerging Contributor
I'm trying to create a simple flex viewer app that will display a popup or hovertip containing a raster pixel value.  I have searched the forums and haven't found any way to do this with the ArcGIS viewer for Flex.  I was thinking perhaps it would be possible using the geoprocessing widget and a geoprocessing service (ie. extract values from points).

If it can't be done with the viewer, is this possible using the ArcGIS API for flex?  I am running ArcGIS Server 9.3.

Any help would be appreciated.
Tags (2)
0 Kudos
25 Replies
RobertScheitlin__GISP
MVP Emeritus
Martyn,

1) In the IdentifyWidget.mxml make these changes:

<mx:Image id="iDrawLine"
                          name="{DrawTool.POLYLINE}"
                          width="40" height="40"
                          buttonMode="true"
                          click="{activateIdentifyTool(event)}"
                          rollOut="iconRollOutHandler(event)"
                          rollOver="iconRollOverHandler(event)"
                          source="assets/images/i_draw_line.png"
                          toolTip="{lineLabel}"
                          useHandCursor="true"
                          visible="false"/>
                <mx:Image id="iDrawExt"
                          name="{DrawTool.EXTENT}"
                          width="40" height="40"
                          buttonMode="true"
                          click="{activateIdentifyTool(event)}"
                          rollOut="iconRollOutHandler(event)"
                          rollOver="iconRollOverHandler(event)"
                          source="assets/images/i_draw_rect.png"
                          toolTip="{rectLabel}"
                          useHandCursor="true"
                          visible="false"/>
                <mx:Image id="iDrawPoly"
                          name="{DrawTool.POLYGON}"
                          width="40" height="40"
                          buttonMode="true"
                          click="{activateIdentifyTool(event)}"
                          rollOut="iconRollOutHandler(event)"
                          rollOver="iconRollOverHandler(event)"
                          source="assets/images/i_draw_poly.png"
                          toolTip="{polyLabel}"
                          useHandCursor="true"
                          visible="false"/>
2) Now I have to assume that you want feet added to all the results and you will not be using the identify widget for any other purpose than to identify your raster layer and it returns one field that you want feet appended to...

            private function onResult(event:IdentifyEvent):void                
            {   
//My stuff
                var identifyResults:Array = event.identifyResults;
                var cFormater:NumberFormatter = new NumberFormatter
                cFormater.precision = "2";
                cFormater.rounding = "nearest";
                cFormater.decimalSeparatorFrom = "."
                cFormater.decimalSeparatorTo = "."
                cFormater.useThousandsSeparator = "false";
//End my stuff
                
                if(!identifyArrayCollection)
                    identifyArrayCollection = new ArrayCollection();
                for each (var identifyResult:IdentifyResult in identifyResults)
                {
                    var title:String = identifyResult.layerName;
                    var obj:Object = identifyResult.feature.attributes;
                    //var content:String = 'X & Y: ' + cFormater.format((identifyResult.feature.geometry as MapPoint).x) + ", " + cFormater.format((identifyResult.feature.geometry as MapPoint).y) + "\n";
                    var content:String = "";
                    var fld:String;
                    var value:String;
                    var link:String = "";
                    var linkicon:String = "";
                    var identFields:String = "";
                    var identLinkPre:String = "";
                    var identLinkField:String = "";
                    var identLinkSuffix:String = "";
                    var identLinkIcon:String = "";
                    var identLinkIconPre:String = "";
                    var identLinkIconSuffix:String = "";
                    var identZoom:Number = 0;
                    var identForceScale:Boolean = false;
                    var idResult:IdResult = new IdResult();
                    
                    for(var i:int=0; i<configIdentFields.length; i++)
                    {
                        if (identifyResult.layerName == configIdentFields.label)
                        {
                            identLinkField = configIdentFields.linkfield;
                            identFields = configIdentFields.fields;
                            identLinkPre = configIdentFields.linkpre;
                            identLinkSuffix = configIdentFields.linksuffix;
                            identLinkIconPre = configIdentFields.linkiconpre;
                            identLinkIcon = configIdentFields.linkicon;
                            identLinkIconSuffix = configIdentFields.linkiconsuffix;
                            identZoom = configIdentFields.zoomscale;
                            identForceScale = configIdentFields.forcescale;
                        }
                    }
                    
                    if(identFields != "") {
                        var fldArr:Array = StringUtil.trimArrayElements(identFields,",").split(",");
                        for (var f:Number = 0; f < fldArr.length; f++) {
                            try{                                   
                                value = obj[fldArr] ? String(obj[fldArr]) : "";
                            } catch (error: Error){
                                value = "";
                            }
                            value += " Feet";
                           ...........................................................................................................
                           
0 Kudos
MartynSmith
Emerging Contributor
Perfect Robert! your help is truly appreciated.  Well on my way.
0 Kudos
MartynSmith
Emerging Contributor
Perfect Robert! your help is truly appreciated.  Well on my way.


Robert, one more question.  Is there an easy way to just make the "Identify by point" active and keep it active so that as long as you have the identify widget window open, you can keep clicking points?  In other words, not deactivate the Identify tool after a result is returned.
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Martyn,

   Sure if you read the documentation you will see that there is a config setting in the xml for this, keepidentifyactive.
0 Kudos
MartynSmith
Emerging Contributor
Robert-

Just upgraded to Identify Widget 2.5 and was very pleased to see you implemented all of my little tweaks! this is great.  Appreciate your time on this.

Martyn
0 Kudos
RobertMarin
Emerging Contributor
Martyn,
I saw this thread and have trying to get the identify widget to return a pixel value from a raster (a DEM), but no luck. Vector layers work just fine. (Being a newbie, I am using flexbuilder 3.1, not the API). 

I built a raster attribute table (integer) and created an elevation field, published the DEM as a map service and loaded it into the builder, but the widget doesn't seem to recognize the raster field. I notice in the REST services that my DEM layer doesn't show a display field (even though one is selected in the source) .mxd. What step(s) am I missing here?
Rob
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
All,

  Configuring the identification of raster layers is now supported in the 3.1.2 version of the Identify Widget.
0 Kudos
LeonardoAraújo
Deactivated User
All,

  Configuring the identification of raster layers is now supported in the 3.1.2 version of the Identify Widget.



Hi Robert,

Could you tell me how do I configure the identification of raster layers to get the pixel value? I have not seen anything about this in the IdentifyWidget.xml file.

I'm already using the version 3.1.4 of the widget.

Thanks.
0 Kudos
RhettZufelt
MVP Notable Contributor
I'm trying to figure this out also.  I have it working in 3.1.2f, but that one will give me null value errors if I have run the ElevationProfileWidget previously so I tried to upgrade, but can't figure out how to get 3.1.4 to identify raster values from AGS 10.05.

However, it seems to work with AGS 10.1.  Will this only support rasters on 10.1, or is it something I'm doing differently?

Thanks,

R_

Noticed that even using AGS 10.1, I can only get raster values if I select All Layers and must have onlythese="false".  If I pick the actuall elevation data, I get no results found.

Not sure, but might be related to the fields tag as I can't get it to display anything if I try to make it follow them.

This used to work in older version:
    <field name="Pixel Value" alias="NAVD88 (m)"  numberformat="2|,|." />
but doesn't anymore.  Odd, as if I let it identify it will all layers, it shows Pixel Value and Class Value, but can't figure out how to honor it in the fields tag.

Seems the only way I can get it to work is onlythese="false", then exclude all the other layer/sublayers in the map.
0 Kudos
RhettZufelt
MVP Notable Contributor
More on this.  It seems that both AGS 10 and 10.1 will identify, however, I don't know how to get it to honor the fields tag in 10.1.

with 10.05, it honors my field tag, and will work with onlythese="true", but since I don't have the proper syntax for 10.1, it will only work if I have it set to onlythese="false", but get no field formatting.

R_
0 Kudos