I am trying to copy a geodb to a different name, do work on the copy, then overwrite the original. My error checking fails before it can even start.
My error checking is to make sure the projection is correct before continuing on that (copied) FC. What I'm running into is changing arcpy.env.workspace "on the fly" to the newly created geodb; it can't find the FC's to check the projection.
I've narrowed the snippet below to just show the error generated (and only one list item), not the work I'm trying to do. I have tried all manner of things trying to put a string together for the "on the fly" part.
Python 2 because that's all they have.
Spoilerimport arcpy
### Lists
geodb_list = [r"S:\GIS\Scratch\Conversion2\GISPWBASE.gdb"]
# Note that 2nd file exists: "S:\GIS\Scratch\Conversion2\GISPWBASE.gdbsp.gdb"
for geodb in geodb_list:
env = str(geodb)
ext = "sp.gdb"
geodb2 = str(env+ext)
arcpy.env.workspace = env
feature_classes = arcpy.ListFeatureClasses()
print feature_classes
for fc in feature_classes:
spatial_ref = arcpy.Describe(fc).spatialReference
print (spatial_ref.name)
#
arcpy.env.workspace = geodb2
feature_classes = arcpy.ListFeatureClasses()
print feature_classes
for fc in feature_classes:
spatial_ref = arcpy.Describe(fc).spatialReference
print (spatial_ref.name)
#OUTPUT
[u'Locates', u'Easements', u'NWGASMAPS', u'NWNaturalGas', u'namedstreams', u'lakes_rivers', u'LocatesAnno', u'addresses', u'Taxlots', u'Roads', u'TheDallesIrrigation']
NAD_1927_StatePlane_Oregon_North_FIPS_3601
NAD_1927_StatePlane_Oregon_North_FIPS_3601
NAD_1927_StatePlane_Oregon_North_FIPS_3601
NAD_1927_StatePlane_Oregon_North_FIPS_3601
NAD_1927_StatePlane_Oregon_North_FIPS_3601
NAD_1927_StatePlane_Oregon_North_FIPS_3601
NAD_1927_StatePlane_Oregon_North_FIPS_3601
NAD_1927_StatePlane_Oregon_North_FIPS_3601
NAD_1927_StatePlane_Oregon_North_FIPS_3601
NAD_1927_StatePlane_Oregon_North_FIPS_3601
NAD_1927_StatePlane_Oregon_North_FIPS_3601
[u'Locates', u'Easements', u'NWGASMAPS', u'NWNaturalGas', u'namedstreams', u'lakes_rivers', u'LocatesAnno', u'addresses', u'Taxlots', u'Roads', u'TheDallesIrrigation']
Traceback (most recent call last):
File "<module1>", line 37, in <module>
File "C:\Program Files (x86)\ArcGIS\Desktop10.7\arcpy\arcpy\__init__.py", line 1260, in Describe
return gp.describe(value, data_type)
File "C:\Program Files (x86)\ArcGIS\Desktop10.7\arcpy\arcpy\geoprocessing\_base.py", line 376, in describe
self._gp.Describe(*gp_fixargs(args, True)))
IOError: "Locates" does not exist Thanks,
Tycho