centroid of the polygon

5035
4
03-30-2011 06:48 AM
nidhiarora
New Contributor
Hi,
I want to calculate the centroid of the polygon .  I tried using Polygon.getExtent().getCenter( ) , but this fn does not return the true center , for example , if the polygon is C shaped.
Any thoughts in this aspect will be appreciated.

Regards,
Nidhi.
0 Kudos
4 Replies
HemingZhu
Occasional Contributor III
Hi,
I want to calculate the centroid of the polygon .  I tried using Polygon.getExtent().getCenter( ) , but this fn does not return the true center , for example , if the polygon is C shaped.
Any thoughts in this aspect will be appreciated.

Regards,
Nidhi.


If the polygon is the result of a task(find, query, identify) on a map/feature service, you could add two fields (x, y) on the polygon layer and populate centroid's x and y using calculate geometry on ArcMap. So when you got the polygon, you could fetch x and y using graphic attributes["x"] and attributes["y"].  If the polygon is the result of a drawing, sorry the current JS api esri.Geometry doesn't have such method as getTrueCentroid. In this case, you might want to create a samll python script as a gp service to calculate centroid of the polyon. Because in Arcpy, Geometry does have a method like trueCentroid(or something like that-can't remember exactly). Another thought: A polyon locator will return centroid point as a result...
0 Kudos
nidhiarora
New Contributor
thnx a lot for your inputs. I ll try the GP service.
0 Kudos
BryanBaker
Occasional Contributor
This is a little late, but you might find the GeometryService.labelPoints() method useful here. It will return a point that is guaranteed to be within the polygon. It may not be the literal centroid, but it sounds like you're more concerned about the point being within the polygon.

http://help.arcgis.com/en/webapi/javascript/arcgis/help/jsapi/geometryservice.htm#labelPoints
0 Kudos
El_BoukfaouiReda
New Contributor II
Hi Everyone,


I am aiming to consume a Public Building Plot areas Map service through ArcMap and generate/export the plots centroids to a feature class to another location. Is there any geoprocessing tool/service able to perform this on a Map service?


Ref.
There is this python script that calculates the centroids of polygon feature classes but only locally :
Calculate centroids (http://resources.arcgis.com/en/help/main/10.1/index.html#//00170000004m000000)


Please Help !
0 Kudos