8

Is it possible to calculate points XY coordinates in Decimal Degrees in model or script when a feature class is in projected coordinate system?

It's easy when a FC is in geographic coordinate system:

  • using Add XY Coordinates tool or
  • using Python expression eg. !shape.extent.XMax!

I've found that area and length properties of geometry field can be modified with geometry unit conversion keyword. For linear units of measue one can use @DECIMALDEGREES.
Unfortunatelly, !shape.extent.XMax@decimaldegrees! doesn't work as XMax is not a length.

In Calculate Geometry function (accessed from right-click) there's a possibility to choose Decimal Degrees output type even for projected feature class.
Can I do this using ArcPy?


Here's a code snippet based on iRfAn's solution:

import arcpy, os
projectedFC = r"C:\tmp\test.gdb\points01_Projected"
prjFile = os.path.join(arcpy.GetInstallInfo()["InstallDir"],
            r"Coordinate Systems\Geographic Coordinate Systems\World\WGS 1984.prj")
spatialRef = arcpy.SpatialReference(prjFile)

updCursor = arcpy.UpdateCursor(projectedFC,"", spatialRef)
for row in updCursor:
    pnt = row.Shape.getPart(0)
    row.X = pnt.X
    row.Y = pnt.Y
    updCursor.updateRow(row)

del updCursor, row
2
  • Is it a necessity to keep the XY points in a projected CS?
    – Roy
    Commented Jul 13, 2012 at 11:14
  • @Roy: yes, I want to preserve a feature class in projected CS, but calculated decimal degrees.
    – Marcin
    Commented Jul 13, 2012 at 11:19

2 Answers 2

4

I think you can.

Just define the Spatial Reference in WGS-84 and use cursor using this Spatial Reference.

Coordinates are specified in the spatial_reference provided, and converted on the fly to the coordinate system of the dataset.

Fore more detail see this.

1
  • You can do it this way. From the SHAPE field you'll get a point geometry object, from which you can get the X and Y coords.
    – om_henners
    Commented Jul 13, 2012 at 15:17
2

I'm not sure about a script, but I've this accomplished in a somewhat automated fashion using model builder: import your xy coordinates and project them into WGS 1984. Then add fields and calculate the geometry of the points in decimal degrees. Then bring your XY points back into the original coordinate system.

2
  • it is long way to go, i will rather use cursor and use WGS-84 as Spatial Reference and calculate. No need to re projecting and after then joining.
    – iRfAn
    Commented Jul 16, 2012 at 8:09
  • @mburkenysdot: This is a good workaround when someone doesn't want to use any scripting.
    – Marcin
    Commented Jul 16, 2012 at 10:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.