AnsweredAssumed Answered

Schema lock woes in ArcGIS Pro 2.3

Question asked by eric.eagle on May 6, 2019
Latest reply on May 7, 2019 by eric.eagle

Can someone tell me in my code where I'm not properly dismissing schema locks?  Currently when I attempt to run the tessellation, I get ERROR 000464: Cannot get exclusive schema lock.  Either being edited or in use by another application.


In this case I am not running the application, only the IDE.  What am I missing?


Background: I am taking huge point data files that come to me unprojected, automating a UTM zone projection to put it into metric units, and then making a determination of whether the extent is so big (it fluctuates) that it warrants splitting into smaller chunks, which I will do through tessellation.  I am not using minimum bounding geometry because Esri has helpfully limited the Envelope functionality to advanced licenses, and all of my users are on standard licenses


import arcpy

def get_vector_center(vector):
    sample_mean = "sample_mean"
    sample_center = arcpy.MeanCenter_stats(vector, "in_memory/{}".format(sample_mean))
    return sample_center

tempgdb = "C:/Temp/scratchdb.gdb"
input_sample = "C:/Temp/dots.shp"

arcpy.env.workspace = tempgdb
arcpy.env.overwriteOutput = True

# prep data
utm_fc = "C:/Temp/foundation.gdb/utm_zones_with_epsg"
center = get_vector_center(input_sample)

# do a join
utm_zone = arcpy.SpatialJoin_analysis(utm_fc, center, "in_memory/zone", "#", "KEEP_COMMON", "#", "CONTAINS")

# get the zone
with arcpy.da.SearchCursor("in_memory/zone", ['EPSG']) as vcursor:
    for row in vcursor:
        epsg = (int(row[0]))
print("Got EPSG code {}".format(epsg))

# construct the sr object
sr = arcpy.SpatialReference(epsg)
sr.factoryCode = epsg

# project the original content with the right utm zone
output_layer = "output_utm"
fixed_data = arcpy.Project_management(input_sample, output_layer, sr)

# now manually create envelope in correct projection since no advanced license

e = arcpy.Describe(output_layer)

xmin = e.Extent.XMin
ymin = e.Extent.YMin
xmax = e.Extent.XMax
ymax = e.Extent.YMax

coordinates = [(xmin, ymin), (xmin, ymax), (xmax, ymax), (xmax, ymin)]
polygon = arcpy.CreateFeatureclass_management(tempgdb, "poly_from_extent", "POLYGON", spatial_reference=sr)
feature_class = polygon[0]

# write the geometry from extent to create envelope

with arcpy.da.InsertCursor(feature_class, ['SHAPE@']) as cursor:

o = arcpy.Describe(feature_class)

# now check for >100km2 area to see if we should tesselate for faster processing

t_out = "parent_tgrid"
oe = o.Extent

with arcpy.da.SearchCursor(feature_class, 'SHAPE@AREA') as acursor:
    for row in acursor:
        if row[0] > 100000000:
            print("{} greater than 10K km2, splitting...".format(row[0])
            tgrid = arcpy.GenerateTessellation_management(t_out, oe, "SQUARE", 100000000, sr)
            print("Splitting complete")
            print("point extent smaller than 10K km2, not splitting.")