Coordinate calculation within script, coordinate system name error

430
3
02-28-2023 01:09 PM
Seyed-MahdySadraddini
New Contributor III

Hello

I have written a script and within it I try to calculate coordinate values based on WGS 1984 GCS. I wrote the below line:

arcpy.management.CalculateGeometryAttributes(points_name, ['Y', 'POINT_Y'], coordinate_system='WGS1984')

However, the name of the coordinate system is causing an error. Any suggestion what should the name be?

0 Kudos
3 Replies
JeffHanson2
New Contributor III

You probably need to use the WKID (Well Known ID) which for WGS 1984 GCS is 4326.

Well-Known ID
 
The Well-Known ID (WKID) is a unique number assigned to a coordinate system. You can find the WKID in the Coordinate Systems Details window. Once you know this number, it's a handy way to search for the coordinate system later.
0 Kudos
DavidAnderson_1701
Occasional Contributor

This is one of the times I find the UI helpful.  Fire up pro, do the operation manually, open up the analysis tools history, copy the the function as a python snippet, paste that somewhere, copy out the correct string for the coordinate system, put that into your code.

Another option is if the script touches a feature layer with the desired coordinate system, the script can query out the coordinate system value, stash that into a variable and use the variable in the calculategeometry operation.

 

0 Kudos
by Anonymous User
Not applicable

Maybe add the space between WGS and 1984.  'WGS 1984'

edited to add using the spatial reference object since the docs do not show it and the method might not cast it from the 'WGS 1984' string:

sr = arcpy.SpatialReference('WGS 1984')

arcpy.management.CalculateGeometryAttributes(points_name, ['Y', 'POINT_Y'], coordinate_system=sr)

 

0 Kudos