To provides some additional info, this is where user input is provided and you can see the out_workspace variable is where I'm getting the path to the project gdb. I've tried changing this text input adding the 'r' and only having the gdb name with file ext and that's how the 11 methods before this one all worked fine, so I just don't know. Everything is run from the root directory and I haven't had any issues until now.
from prepare import Prep
from process import Proc
if __name__ == "__main__":
# Input the abbreviation for the state you want to process.
in_state = "WY"
# This epsg code is meant to be the best projection for the entire state, usually a UTM zone or a custom state projection.
# If you aren't sure which epsg code to use, stick with NAD83 GCS ('4269') or you can try leaving a blank string ''.
epsg = "4269"
# The wetlands_gdb path below may need to be altered if the shared drive file structure changes.
wetlands_gdb = "..\\..\\..\\DATA\\USFWS\\National_Wetlands_Inventory\\20220524_By_State\\{}_geodatabase_wetlands\\{}_geodatabase_wetlands.gdb".format(in_state, in_state)
# Your local project file geodatabase. Include '.gdb' in string.
out_workspace = r".\\WY_testing.gdb"
blob_size = 500
#prep = Prep(in_state, epsg, wetlands_gdb, out_workspace)
proc = Proc(out_workspace, blob_size)
And this is the Proc class with just the method I'm having issues with:
import os, sys
import arcpy
class Proc():
def __init__(self, out_workspace, blob_size):
self.work = out_workspace
self.blob_size = blob_size
arcpy.env.workspace = self.work
self.fc_list = arcpy.ListFeatureClasses()
self.parcels = [f for f in self.fc_list if 'parcels_over20' in f][0]
self.subs = [f for f in self.fc_list if 'subs_inservice' in f][0]
self.boundary = [f for f in self.fc_list if 'boundary' in f][0]
self.wetlands = [f for f in self.fc_list if 'Wetlands' in f][0]
self.nlcd_vector = [f for f in self.fc_list if 'nlcd_vector' in f][0]
self.subs_buff_out = '{}\\subs_buff_poly'.format(self.work)
self.parcels_buff_out = '{}\\parcels_over20_buffselect'.format(self.work)
self.blobs_out = 'blobs'
self.blobs_exp = 'blobs_exp'
self.blob_creator(
self.work, self.parcels_buff_out, self.blob_size, self.blobs_out, self.blobs_exp
)
# 12 --- create blobs with acreage_calc and removes any less than 'blob_size'
def blob_creator(self, work, parcels_out, blob_size, blobs_out, blobs_exp):
print('12 --- blob creator started')
# below this does successfully print
if arcpy.Exists(work):
print('gdb does exist!')
try:
arcpy.env.workspace = work
arcpy.analysis.Buffer(parcels_out, blobs_out, '25 Feet', 'FULL', 'ROUND', 'ALL')
if arcpy.Exists(blobs_out):
# run multipart to singlpart to separate unique blobs
arcpy.management.MultipartToSinglepart(blobs_out, blobs_exp)
print('blobs_exp feature count:', arcpy.management.GetCount(blobs_exp))
if arcpy.Exists(blobs_exp):
arcpy.management.Delete(blobs_out)
arcpy.management.AddField(blobs_exp, 'acreage_calc', 'DOUBLE')
desc = arcpy.Describe(blobs_exp)
print('blobs_exp datatype:', desc.dataType)
arcpy.management.AddGeometryAttributes("{}".format(blobs_exp), 'AREA_GEODESIC', '', 'ACRES')
else:
sys.exit('12 --- could not find exploded blobs')
else:
sys.exit('12 --- could not find blobs poly')
except Exception as e:
print('12 error ---', e)