ArcPy – Convert Map Units from Feet to Decimal Degrees

arcpy

This is my problem:
I have an arcpy script that finds the XMax, XMin, YMax, and YMin of a polygon. It shows the results in feet, but I want them to be in decimal degrees.

In ArcMap I can change the data frame's display units to decimal degrees. But every time I run my script it shows the numbers in feet again.

Is there a solution for this in arcpy?

Best Answer

You can define a SearchCursor on the layer holding the polygon, and specify a spatial reference:

When specified, features will be projected on the fly using the spatial_reference provided.

See the help file under Setting a cursor's spatial reference for more info on setting up the search cursor with a new coordinate system. Once you've defined the cursor, you can find the projected extent using:

rows = arcpy.SearchCursor(featureclass,query,spatialReference)
row = rows.next()
polygon = row.shape
extent = polygon.extent
Related Question