Hi All,
I'm trying to use Esri python API to access a raster in out SDE database and rename it. This is my shocking attempt at coding it.
Username1_0-1727438145021.png
For context:
The ultimate goal is at the time of loading data to our Shared SDE, check for a raster dataset with the same name and then take a copy of the version in Shared, rename it and save to our Archived SDE. Then overwrite the Shared version with the new version being loaded. I have an FME workbench that does the checking and archiving steps but I'm struggling to rename raster data so have turned to python but I have very little experience when it comes to coding. Any help would be appreciated.
Username1_1-1727438208777.png
Solved! Go to Solution.
You need to set your workspace environment before executing rename. This lets arcpy know where the data you are referencing by name only lives. Otherwise, I think you can use the full path to the data in rename.
Example setting workspace environment:
https://pro.arcgis.com/en/pro-app/latest/tool-reference/data-management/rename.htm
# Import system modules
import arcpy
# Set workspace
arcpy.env.workspace = "C:/workspace/test.gdb"
# Set local variables
in_data = "test"
out_data = "testFC"
data_type = "FeatureClass"
# Run Rename
arcpy.management.Rename(in_data, out_data, data_type)
You need to set your workspace environment before executing rename. This lets arcpy know where the data you are referencing by name only lives. Otherwise, I think you can use the full path to the data in rename.
Example setting workspace environment:
https://pro.arcgis.com/en/pro-app/latest/tool-reference/data-management/rename.htm
# Import system modules
import arcpy
# Set workspace
arcpy.env.workspace = "C:/workspace/test.gdb"
# Set local variables
in_data = "test"
out_data = "testFC"
data_type = "FeatureClass"
# Run Rename
arcpy.management.Rename(in_data, out_data, data_type)