Select to view content in your preferred language

Measure Polygons vertices Length??

5628
11
08-21-2010 09:25 PM
sangeethaunni
Emerging Contributor
Hi All,

How do we get length of each vertex of a selected Polygon?
I have Parcle.shp with AREA & LEN in the .gdb . Now need to show length of each Side of the Selected Parcel.
how do I implement it? Can we have any tool in AGS Desktop 10? or we have to add code in flex?
My scnario as in calhounty parcel search.
Tags (2)
0 Kudos
11 Replies
RobertScheitlin__GISP
MVP Emeritus
Sangeetha.

   You are going to have to be more specific as to what you are trying to do. I can not think of anything on my site that has to do with measuring polygons length.
0 Kudos
sangeethaunni
Emerging Contributor
Thank u for the response

My scenario is as follows:
               Search a Parcel by its parcel ID & highlight the selected polygon. Mean while i want to find the length of each side the selected feature polygon.
I have attached a snap shot of my flex page. In that i could able to add 'short axis X long axis' label by using Azimuth polygon tool.

Can i find length of each side of selected polygon?
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Sangeetha,

   Here is a sample app where you draw a polygon on the map and the length of the sides are alerted back to you.

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
      xmlns:s="library://ns.adobe.com/flex/spark"
      xmlns:mx="library://ns.adobe.com/flex/mx"
      xmlns:esri="http://www.esri.com/2008/ags"
      pageTitle="Basic usage of DrawTool" creationComplete="init()">
 
 <s:layout>
  <s:VerticalLayout paddingBottom="5"/>
 </s:layout>
 
 <fx:Style>
  @namespace mx "library://ns.adobe.com/flex/mx";  
  mx|ToolTip
  {
   font-size: 14;
  }
 </fx:Style>
 
 <fx:Script>
  <![CDATA[
   import com.esri.ags.events.DrawEvent;
   import com.esri.ags.events.GeometryServiceEvent;
   import com.esri.ags.geometry.Geometry;
   import com.esri.ags.geometry.MapPoint;
   import com.esri.ags.geometry.Polygon;
   import com.esri.ags.geometry.Polyline;
   import com.esri.ags.tasks.supportClasses.LengthsParameters;
   import com.esri.ags.tasks.supportClasses.LinearUnit;
   
   import mx.controls.Alert;
   
   import spark.events.IndexChangeEvent;
   
   protected function GeoServe_lengthsCompleteHandler(event:GeometryServiceEvent):void
   {
    var distArr:Array = event.result as Array;
    var dist:Number
    var distTxt:String = "";
    for each(dist in distArr){
     distTxt += "Side Length: " + dist.toString() + "\n";
    }
    Alert.show(distTxt);
   }
   
   protected function init():void
   {
    drawTool.activate(DrawTool.POLYGON);
   }

   protected function drawTool_drawEndHandler(event:DrawEvent):void
   {
    var geom:Geometry = event.graphic.geometry;
    var plArr:Array = [];
    
    var poly:Polygon = geom as Polygon;
    var mpArr:Array = poly.rings[0];
    var mp:MapPoint;
    var pl:Polyline;
    for (var i:int = 1; i < mpArr.length; i++)
    {
     var pla:Array = [];
     pla.push(mpArr[i - 1]);
     pla.push(mpArr);
     pl = new Polyline([pla],myMap.spatialReference);
     plArr.push(pl);
    }
    
    var lengthsParameters:LengthsParameters= new LengthsParameters();
    lengthsParameters.geodesic = true;
    lengthsParameters.polylines = plArr;
    GeoServe.lengths(lengthsParameters);
   }

  ]]>
 </fx:Script>
 
 <fx:Declarations> 
  <!-- Symbol for all line shapes -->
  <esri:SimpleLineSymbol id="sls"
          color="0x00FF00"
          width="3"/>
  
  <!-- Symbol for all polygon shapes -->
  <esri:SimpleFillSymbol id="sfs"
          color="0xFFFFFF"
          style="diagonalcross">
   <esri:outline>
    <esri:SimpleLineSymbol color="0x00FF00" width="2"/>
   </esri:outline>
  </esri:SimpleFillSymbol>
  
  <esri:DrawTool id="drawTool"
        fillSymbol="{sfs}"
        graphicsLayer="{myGraphicsLayer}"
        lineSymbol="{sls}"
        map="{myMap}"
        drawEnd="drawTool_drawEndHandler(event)"/>
  <esri:GeometryService id="GeoServe" lengthsComplete="GeoServe_lengthsCompleteHandler(event)"
         url="http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer"/>
 </fx:Declarations>
 
 <esri:Map id="myMap" level="3">
  <esri:ArcGISTiledMapServiceLayer url="http://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer"/>
  <esri:GraphicsLayer id="myGraphicsLayer"/>
 </esri:Map>
  
</s:Application>
0 Kudos
NormandMarchand
Emerging Contributor

i am looking for similar help. I need to display length of each vertex's in the polygon.  help would be much appreciated. 

0 Kudos
sangeethaunni
Emerging Contributor

you may use the code provided in the forum .

I forgot what did I do for resolving.

I hope I had used the same code.

0 Kudos
NormandMarchand
Emerging Contributor

where do i input that code?

0 Kudos
sangeethaunni
Emerging Contributor

If you are using adobe Flex code for development , you may use this code to

execute it

0 Kudos
NormandMarchand
Emerging Contributor

also, I don't need to draw in any polygons I just need it to display the length of each polyline in each polygon. 

0 Kudos
NormandMarchand
Emerging Contributor

i tried the code it did not work 

0 Kudos