jwolff

get cursor spatial reference from current map data frame?

Discussion created by jwolff on Dec 2, 2016
Latest reply on Dec 2, 2016 by jwolff

Is it possible to use the coordinate system from a data frame in the current map document within an update cursor?

 

I have data in GCS WGS84 and I want to update area/perimeter/length fields across a geodatabase with UTM WGS84 units.  I want to acquire a coordinate system for the cursor from the current map data frame coordinate system, not a reference feature class.  A piece of my current script is below, which would return useless area/length values from GCS coordinates:

 

for fc in fcList:
        fc = fc +"\\"
        fieldList = arcpy.ListFields(fc, 'lengthSize')#lengthSize field
        fieldCount = len(fieldList)
        if (fieldCount > 0):
            print "perimeterSize field present in: " + fc
            arcpy.AddMessage ("perimeterSize field present in: " + fc)
            with arcpy.da.UpdateCursor (fc, ['SHAPE@LENGTH', 'lengthSize']) as cursor:
                for row in cursor:
                    row[1] = row[0]
                    cursor.updateRow(row)
                    print "Updating 'lengthSize' field in: " + fc
                    arcpy.AddMessage ("Updating 'lengthSize' field in: " + fc)
        else:
            print "No lengthSize field in: ", fc
            arcpy.AddMessage ("No lengthSize field in: " + fc)

 

Is this possible, or does a "describe" (like that found here: http://pro.arcgis.com/en/pro-app/arcpy/get-started/setting-a-cursor-s-spatial-reference.htm) have to be used?

Thanks

Justin

Outcomes