# Calculating geometry for feature class with x/y and Lat/Long values in different projections?

I have a feature class with x/y values populated on the native projection of the feature class (state plane).

In the same feature class I also have Lat/Long fields that I need to populate (WGS 84 in decimal degree).

The problem I have is the calculate geometry function doesn't allow me to choose a different projection other than State Plane when I try to auto populate the Lat/Long values.

Does anyone have any python code or ideas that might help with this request?

• Add the data to ArcMap, set the data frame to WGS 84 (set a geographic transformation if needed!). Now try calculate geometry. Aug 19, 2015 at 20:06
• Also asked on GeoNet Aug 19, 2015 at 20:07

you just need to run a cursor on it and use the `projectAs()` geometry method.

``````import arcpy

fc = r'C:\path_to\your_data\points.shp'

wgs = arcpy.SpatialReference(4326)
with arcpy.da.UpdateCursor(fc, ['SHAPE@', 'lat_field', 'long_field']) as rows:
for row in rows:
pnt_wgs = row.projectAs(wgs)
row[1:] = [pnt_wgs.centroid.Y, pnt_wgs.centroid.X] #will be in decimal degrees
rows.updateRow(row)
``````
• Thanks for your help cmackey...when I run that code I get an error as follows.....AttributeError: 'module' object has no attribute 'spatialReference'.....any ideas on that? Aug 20, 2015 at 18:38
• Looks like you need to capitalize the `S` in `SpatialReference`. Python is a case sensitive language. Aug 20, 2015 at 19:49

If you have access to ArcMap 10.2.1+, you can use Add Geometry Attributes, which allows you to specify a coordinate system.

``````spatref = arcpy.SpatialReference(4326) #WGS 84
It's a script, not a tool, which means that you can inspect the code behind it to see what it does. It's similar to the answer posted by @crmackey, though it utilizes the `spatial_reference` parameter of `UpdateCursor`.