AnsweredAssumed Answered

How can search and insert cursors be used to duplicate points?

Question asked by cbevilacqua on Jan 5, 2017
Latest reply on Jan 9, 2017 by cbevilacqua

I'm trying to use Python to duplicate points in a file geodatabase feature class using an insert cursor in combination with a search cursor.  The points represent wells, and I want to create a duplicate point for each geologic reservoir with which the well is associated.  A where clause in the search cursor is used to identify the points to be duplicated, and then the insert cursor replicates the rows in the search cursor, with some minor modifications.  This appears to work fine when I run the code with the first reservoir.  So I copy and past that bit the code, make some minor modifications to reflect the next reservoir for which I want to create duplicates, and run it again.  The problem is that each time I run the block of code, I get additional records inserted into the feature class.  In other words, there are 63 wells that meet the criteria for duplication.  When I duplicate these with the cursors for ATOKA, 63 rows is what I get.  However, I get 68 CLFKL records and 78 CLFKU records.  I want to do this for a total of 10 reservoirs.  By time I get to the 8th or 9th one, the code appears to hang but is actually creating rows.  I let it run overnight and had a feature class with almost a GB of points the next morning.  

 

I'm using ArcGIS 10.1 and PyScripter.  

 

Here's a sample of the code:

import arcpy

allPoints = r'\\GIS\allPoints'

# Duplicate features for Clear Fork, Lower Wolfcamp, Strawn, Wolfberry vertical wells in allPoints fc and calculate fcEUR values
# Create search cursor to identify Clear Fork, Strawn, and Wolfberry values in allPoints fc
try:
    print "Duplicating vertical wells - ATOKA"
    whereClause = "\"RESERVOIR\" = 'CLEAR FORK' OR \"RESERVOIR\" = 'STRAWN' OR \"RESERVOIR\" = 'WOLFBERRY' AND \"EUR\" IS NOT NULL AND \"RESERVOIR2\" IS NULL"

    sCur = arcpy.da.SearchCursor(allPoints,["SHAPE@XY","PROPNUM","WellID","RESV_CAT","RESERVOIR","HORIZONTAL","EUR","VOOIPratio","fcEUR","RESERVOIR2"],whereClause)

    #Create insert cursor that will be used to create duplicate points that represent each vertical well within the Atoka formation.
    iCur = arcpy.da.InsertCursor(allPoints,["SHAPE@XY","PROPNUM","WellID","RESV_CAT","RESERVOIR","HORIZONTAL","EUR","VOOIPratio","fcEUR","RESERVOIR2"])

    for sRow in sCur:
        XY = sRow[0]
        PROP = sRow[1]
        WellID = sRow[2]
        RESV_CAT = sRow[3]
        RES = sRow[4]
        HZ = sRow[5]
        EUR = sRow[6]
        VOOIPratio = 0.00425532
        fcEUR = sRow[6] * 0.00425532
        RES2 = "ATOKA"

        iCur.insertRow((XY,PROP,WellID,RESV_CAT,RES,HZ,EUR,VOOIPratio,fcEUR,RES2))

    del sCur, iCur
    del sRow

except Exception as e:
    print (e.message)

###########
try:
    print "Duplicating vertical wells - CLFKL"
    whereClause = "\"RESERVOIR\" = 'CLEAR FORK' OR \"RESERVOIR\" = 'STRAWN' OR \"RESERVOIR\" = 'WOLFBERRY' AND \"EUR\" IS NOT NULL AND \"RESERVOIR2\" IS NULL"

    sCur = arcpy.da.SearchCursor(allPoints,["SHAPE@XY","PROPNUM","WellID","RESV_CAT","RESERVOIR","HORIZONTAL","EUR","VOOIPratio","fcEUR","RESERVOIR2"],whereClause)

    #Create insert cursor that will be used to create duplicate points that represent each vertical well within the CLFKL formation.
    iCur = arcpy.da.InsertCursor(allPoints,["SHAPE@XY","PROPNUM","WellID","RESV_CAT","RESERVOIR","HORIZONTAL","EUR","VOOIPratio","fcEUR","RESERVOIR2"])

    for sRow in sCur:
        XY = sRow[0]
        PROP = sRow[1]
        WellID = sRow[2]
        RESV_CAT = sRow[3]
        RES = sRow[4]
        HZ = sRow[5]
        EUR = sRow[6]
        VOOIPratio = .1617021
        fcEUR = sRow[6] * .1617021
        RES2 = "CLFKL"

        iCur.insertRow((XY,PROP,WellID,RESV_CAT,RES,HZ,EUR,VOOIPratio,fcEUR,RES2))

    del sCur, iCur
    del sRow

except Exception as e:
    print (e.message)
##############

 

 

Any suggestions would be greatly appreciated.

Outcomes