Select to view content in your preferred language

Problem in calculating area of polygon through geometry service in ArcGIS API 1.3

932
4
11-26-2010 11:11 PM
AdeelAhmed
Deactivated User
Hi,
I am trying to calculate area of polygon using geometry service method arealenghts but it is not returning correct area infect it is returning area in negative.i am using ArcGIS API 1.3 for flex.i am using spatialReference (wkid=4326).below is code i am using

var ploy:Polygon = new Polygon();
poly.addRing(pntArray);              //making polygon from mapPoints array
poly.spatialReference = new SpatialReference(4326);

var gra:Graphic = new Graphic();
gra.geometry= poly;
graphiclayer.add(gra);

geomService.addEventListener(GeometryServiceEvent.AREA_LENGHTS_COMPLETE,areaslenghtsCompleteHandler);

geomService.areasAndLenghts([gra]);


private function areaslenghtsCompleteHandler(event:GeometryServiceEvent):void
{
txtArea.label ="Area is "+numFormatter.format(event.arealenghts.areas/1000000)+ " Km2"); //here       area is return from geomservice is negative.
}

Any help in this regard is very helpful and any code that can solve my problem .

Regards
Ahmed
Tags (2)
0 Kudos
4 Replies
RobertScheitlin__GISP
MVP Emeritus
Ahmed,

    If your area is being returned as a negative than you are sending your points array for the polygons ring in a counter clockwise order. All you need to do is add your points yo your pntArray in reverse instead.
0 Kudos
AdeelAhmed
Deactivated User
Thanks for your reply can you send me some sample code to solve this problem actually area returning from geometry service is not negative but it is not correct and in which units it is i.e KM,Meters? e.t.c.
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Adeel,

    There is a good example online for lines

http://help.arcgis.com/en/webapi/flex/samples/index.html?sample=MeasureLine

There are several variables to this. Are you using ArcGIS Server 10? If so then you can specify that units you want the area results to be returned in. If not then you will have to do the unit conversion your self or first reproject the geometry then do the area calculation. Your issue with negative area is the order in which the points are added to the pntArray variable.
0 Kudos
JustinFultz
Regular Contributor
This has nothing to do with this post, but I wanted to get input from Robert on something and didn't know how to get him other than a post he is subscribed to.

Robert or others, please take a look at this post and let me know if you can help. I've been stuck on this one issue for a while and will be almost done with my application once I can get it worked out.

All help is appreciated.


http://forums.arcgis.com/threads/17846-Combine-basemap-layers?p=56514#post56514
0 Kudos