AnsweredAssumed Answered

arcpy.da.InsertCursor   SHAPE_length and SHAPE_Area fields are shown as zero

Question asked by jsn on Aug 4, 2016
Latest reply on Aug 5, 2016 by jsn

Hello everyone,


The goal is to find all the records that were deleted  comparing yesterday and today versions of the same feature class.

I am running a python script that uses cursors. With the curosr I am able to identigy the record that was deleted because it was in the featuer class yesterday but not today.


When I insert a new record using "arcpy.da.InsertCursor", "curAppend.insertRow( rowYesterday)",  two fields SHAPE_length and SHAPE_Area are equal to 0. ArcCatalog does not show any shape information in the preview, but shows only attributes in the Table view. It looks like features were created witout spatial data,  only attributes.


dsc = arcpy.Describe(Layer_DEFAULT)
    fields = dsc.fields
    # List all field names except the OID field
    fieldnames = [ for field in fields if != dsc.OIDFieldName]

    curYesterday = arcpy.da.SearchCursor(Layer_DEFAULT, fieldnames)
    curToday = arcpy.da.SearchCursor(Layer_PREPROD, fieldnames)
    curAppend = arcpy.da.InsertCursor(Layer_D,fieldnames)

    for  rowYesterday in curYesterday:
        # layerID  = layerID
        # datetimeVal  = CRTDATE
        layerID = rowYesterday[0]
        datetimeVal = rowYesterday[4]

        #print rowYesterday[1]
        #print rowYesterday[2]
        #print rowYesterday[3]
        #print rowYesterday[4]
        #print rowYesterday[5]
        #print rowYesterday[0]

        if datetimeVal is not None:

            whereClause = '"AGMID" = %s' % (layerID)

            srcToday = arcpy.da.SearchCursor(Layer_PREPROD, fieldnames, whereClause)

            count = 0

            for  rowToday in srcToday:

                if  rowToday[4] == rowYesterday[4]:
                    count = count + 1

            if count == 0:
                print "Record for Delete :", layerID
      'Delete ' + whereClause)
                curAppend.insertRow( rowYesterday)