# Error when running Extract by Mask Script

I am using ArcGIS 10.3 Desktop to write a script tool to, among other things, extract raster data using a mask.

I keep getting these errors:

ExecuteError: ERROR 000875: Output raster: C:\Users02183940\Documents\Thesis_Data\soil_data\Calculated_Rasters\IL_rasters.gdb\Extract_ph_s1's workspace is an invalid output workspace. ERROR 000581: Invalid parameters. Failed to execute (ExtractByMask).

My code:

import arcpy
from arcpy import env
from arcpy.sa import *
arcpy.env.overwriteOutput = True

ebm_in_raster = r'C:\Users\a02183940\Documents\Thesis_Data\soil_data\Calculated_Rasters\ph_statsgo'

arcpy.CheckOutExtension("Spatial")
env.workspace ='C:\Users\a02183940\Documents\Thesis_Data\soil_data\Calculated_Rasters\IL_rasters.gdb'



What are the requirements for a valid output workspace for this tool? I don't think it is an issue of raster name length or use of unsupported characters as I've tried a few different things and none of them have worked.

• What format are your input data (i.e. ebm_in_raster and ebm_mask_data)? – Aaron Jun 27 '16 at 23:40
• Can you try changing the dash to underscore at the mask filename? – Delonix R. Jun 27 '16 at 23:50
• The input raster and mask raster are both in grid format. It looks like you recommend using .img instead? I'll try that. – Neil Jun 28 '16 at 17:08

There is no need to define the workspace if you are explicitly defining the variable paths. Additionally, you are formatting the paths incorrectly--try using r'C:\path\to\your\data'.

I would recommend writing the output raster to .tif or .img format. As your script is currently configured, it is trying to output a grid format raster.

This is how I would write the script:

import arcpy
from arcpy import env
from arcpy.sa import *
arcpy.CheckOutExtension("Spatial")

arcpy.env.overwriteOutput = True

ebm_in_raster = r'C:\path\to\in_raster.img'  # Assuming a .img source raster