Select to view content in your preferred language

Raster save method using variable

2107
2
Jump to solution
12-27-2013 05:27 AM
anTonialcaraz
Frequent Contributor
Hi,

I'm trying to find out how to permanently save a raster using a workspace variable + Raster name with little success so far.
In the Help it only shows how to do it hard-coding the output.

Please see code below.

import arcpy import string from arcpy import env arcpy.env.overwriteOutput=True from arcpy.sa import * arcpy.CheckOutExtension("Spatial")  # Variables  OutLocation = arcpy.GetParameterAsText(0)  Raster1 = arcpy.Raster(arcpy.GetParameterAsText(1))  Raster2 = arcpy.Raster(arcpy.GetParameterAsText(2))  # Calculation and save  CDF = Raster1 * Raster2  OutFile = "CDF"                          FullOutFile = OutLocation + OutFile     # For example: r"Q:\LFP_GLOBAL\OUTPUT.gdb\CDF" CDF.save(FullOutFile)



Any help would be greatly appreciated.

Many thanks
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
JakeSkinner
Esri Esteemed Contributor
You will just need to add "\\" to your FullOutFile variable.  Ex:

FullOutFile = OutLocation + "\\" + OutFile


Previously you were trying to save the output to:

Q:\LFP_GLOBAL\OUTPUT.gdbCDF

The above will save write the correct path:

Q:\LFP_GLOBAL\OUTPUT.gdb\CDF

View solution in original post

0 Kudos
2 Replies
JakeSkinner
Esri Esteemed Contributor
You will just need to add "\\" to your FullOutFile variable.  Ex:

FullOutFile = OutLocation + "\\" + OutFile


Previously you were trying to save the output to:

Q:\LFP_GLOBAL\OUTPUT.gdbCDF

The above will save write the correct path:

Q:\LFP_GLOBAL\OUTPUT.gdb\CDF
0 Kudos
anTonialcaraz
Frequent Contributor
Once again, thank you very much indeed Jake.
0 Kudos