I am working on a series of geoprocessing tasks and trying to define the output through the concatenation of folders, a geodatabase, and finally a raster dataset. Each way I try it I receive an error stating: TypeError: unsupported operand type(s) for +: 'Result' and 'str'
Below is the code that I have so far with the Project Raster task giving me the error.
import arcpy
import os
#Set Environments
arcpy.env.scratchWorkspace = r"C:/GIS/temp/Subcatchment.gdb"
arcpy.env.overwriteOutput=True
#Create new folder and gdb as well clip and project DEM in WSPLN folder for new project
#Variables
Folder = "C:\GIS\TEMP\Subcatchments"
projectNbr = arcpy.GetParameterAsText(0)
gdbName = arcpy.GetParameterAsText(1)
watershedFC = arcpy.GetParameterAsText(2)
countyDEM = arcpy.GetParameterAsText(3)
outCS = arcpy.GetParameterAsText(4)
outTransformation = arcpy.GetParameterAsText(5)
#Create folder, gdb, and feature classes
projectFolder = arcpy.CreateFolder_management(Folder, str(projectNbr))
arcpy.CreateFolder_management(projectFolder, "MapDocs")
gdbFolder = arcpy.CreateFolder_management(projectFolder, "Geodatabases")
arcpy.CreateFolder_management(projectFolder, "Shapefiles")
gdb = arcpy.CreateFileGDB_management(gdbFolder, gdbName)
#Create buffer and clip county raster in memory
tempBuffer = arcpy.Buffer_analysis(watershedFC, "in_memory" + "\\wsBuffer", "2000 Feet", "FULL", "ROUND", "ALL")
tempRas = arcpy.Clip_management(countyDEM, "#", "in_memory" + "\\tempRas",
tempBuffer, "#", clipping_geometry="ClippingGeometry")
#Project raster to county coords and change units
DEMname = "DEM"
arcpy.ProjectRaster_management(tempRas, gdbFolder + "\\" + gdb + ".gdb" + "\\" + DEMname, outCS, "", "", outTransformation)
GetParameterAsText()
calls with the actual parameter? Also, you should not assign the commands to variables and then try to concatenate those with strings. It is advisable to useos.path.join()
to concatenate paths and strings. – Aaron♦ Jun 9 '17 at 22:44Folder = "C:\GIS\TEMP\Subcatchments"
This will also cause you issues as '\T' is interpreted as a Tab character. Use forward slashes ('C:/path'
) , raw strings (r'C:\path'
) or escape your backslashes ('C:\\path'
). – user2856 Jun 10 '17 at 6:12