Select to view content in your preferred language

Generating a centroid for a polygon

4125
31
10-13-2011 03:15 AM
YousafHassan
Emerging Contributor
Hi
I am trying to help my colleague who wants to select a polygon and then click a button, which would generate a centroid for that polygon. Ideally, he wants a pop-up to appear which would display a copy&pasteable X and Y. He wants this automation as he wants X and Y to be generated for polygons using the same algorithm.

I was thinking of building a custom tool for him using a model. Could anyone please point me to the tools I need in order to achieve this? If you have already written a tool, would you like share it with me? I am quite comfortable in python and VBA but am not so familiar with Arc tools. I would actually prefer to do this in python as the support for VBA won't be there in future.

Any help would be extremely appreciated.
Thanks.
0 Kudos
31 Replies
JamesCrandall
MVP Alum
Sorry, forgot to show you where the point is appearing. See attached.


I see what you mean!

In that case, let's take Alexander's advice and use the LabelPoint of the pArea.  Change this:

pPoint = pArea.Centroid


To this:

pPoint = pArea.LabelPoint
0 Kudos
YousafHassan
Emerging Contributor
I see what you mean!

In that case, let's take Alexander's advice and use the LabelPoint of the pArea.  Change this:

pPoint = pArea.Centroid


To this:

pPoint = pArea.LabelPoint


Great! It's working. All points are now appearing inside the polygons. Thanks, James and Alexander. You have been really helpful.
0 Kudos