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'
ebm_mask_data = r'C:\Users\a02183940\Documents\Thesis_Data\Cropland_Data_Layer\noda_1_10-15'
arcpy.CheckOutExtension("Spatial")
env.workspace ='C:\Users\a02183940\Documents\Thesis_Data\soil_data\Calculated_Rasters\IL_rasters.gdb'
outExtractByMask = ExtractByMask(ebm_in_raster, ebm_mask_data)
outExtractByMask.save('C:\Users\a02183940\Documents\Thesis_Data\soil_data\Calculated_Rasters\ph_in_crl')
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.
1 Answer 1
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
ebm_mask_data = r'C:\path\to\mask_data.img' # Assuming a .img mask
outExtractByMask = ExtractByMask(ebm_in_raster, ebm_mask_data)
outExtractByMask.save(r'C:\path\to\output_raster.img')
Explore related questions
See similar questions with these tags.
ebm_in_raster
andebm_mask_data
)?