Select to view content in your preferred language

find and set point in the center of an ellipse

1521
4
08-19-2010 12:38 AM
ZarzuraMeyer
New Contributor
Dear Forum,

does anyone have an idea how to find the coordinates in the center of an ellipse an set a point there? I have a file with 8 ellipses in the area that i examine. (produced with the drawing function and converted to polygons)Now i want to get out the center coordinates of every ellipse and then the result should be a point file with these centerpoints. I have no idea and hope you'll help

thank you

Chris
0 Kudos
4 Replies
KarlOrmer
Emerging Contributor
For part a) of your task (find center of an ellipse) i got a solution for a circle which should be the same for an ellipse:

import arcgisscripting
gp = arcgisscripting.create(9.3)
print 'Geoprocessor initialised'
circle_path = ur'c:/test/circles.shp'

cursor = gp.SearchCursor(circle_path)
center_points = list()

# let's iterate over all rows in the circle shape
for row in iter(cursor.next, None):
    # get the circle polygon
    circle = row.shape
    # get xmin, xmax etc.
    x_min = circle.extent.XMin
    y_min = circle.extent.YMin
    x_max = circle.extent.XMax
    y_max = circle.extent.YMax
    center_x = x_max - x_min
    center_y = y_max - y_min
    center_points.append((center_x, center_y))

print center_points

If that works you only need a solution for b)
0 Kudos
DanLee
by Esri Regular Contributor
Esri Regular Contributor
Chris,

The geoprocessing tool Feature To Point can produce centroid points from polygons - you get a point feature class as the output:
http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/Feature_To_Point/00170000003m000000/

Then the Add XY Coordinates tool can add the X and Y coordinate fields to the point feature class:
http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/Add_XY_Coordinates/001700000032000000/

Hope that helps. Thanks.
0 Kudos
ZarzuraMeyer
New Contributor
Dan

thank you for answering; the problem is my license. For that tool i need an Arc Info license. I only have access to ArcView...
hm but thanks for trying to help

Chris
0 Kudos
RussellBrennan
Esri Contributor
Chris,

Here is some code that will find and print the centroid of a polygon using a Search Cursor.
import arcpy

polygonfc = 'c:\temp\fgdb.gdb\studyarea'

rows = arcpy.SearchCursor(polygonfc)
    for row in rows:
    feat = row.getValue('SHAPE')
    centroid = feat.centroid
    print centroid
You could then use the centroid values to create points.

Here are some links that you may find useful:
Working with geometry in Python:
http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//002z0000001s000000.htm

Accessing data using cursors:
http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//002z0000001q000000.htm

Insert Cursor:
http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//000v00000038000000.htm
0 Kudos