4

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.

PolyGeo
65.5k29 gold badges115 silver badges349 bronze badges
asked Jun 27, 2016 at 23:23
3
  • What format are your input data (i.e. ebm_in_raster and ebm_mask_data)? Commented Jun 27, 2016 at 23:40
  • Can you try changing the dash to underscore at the mask filename? Commented Jun 27, 2016 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. Commented Jun 28, 2016 at 17:08

1 Answer 1

3

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')
answered Jun 27, 2016 at 23:33

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.