1

I get the following error when I try to extract by mask within a function in my script. When I run the same script separately outside of the function it runs fine. The output is just an intermediate step so I am not looking to save the extracted raster.

ERROR:

Traceback (most recent call last): File "", line 98, in File "", line 20, in PotentialRestoration File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\sa\Functions.py", line 4237, in ExtractByMask return Wrapper( File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\sa\Utils.py", line 55, in swapper result = wrapper(*args, **kwargs) File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\sa\Functions.py", line 4230, in Wrapper result = arcpy.gp.ExtractByMask_sa( File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\geoprocessing_base.py", line 512, in return lambda *args: val(*gp_fixargs(args, True)) arcgisscripting.ExecuteError: Failed to execute. Parameters are not valid. ERROR 000354: The name contains invalid characters Failed to execute (ExtractByMask).

Code:

def PotentialRestoration():  # Potential Restoration scoring calculation

# To allow overwriting outputs change overwriteOutput option to True.
arcpy.env.overwriteOutput = True
LandcoverData = r"c:\Users\datasets\MCD12C1_2021_MLW.tif"
AU = r"c:\Users\test_data\AU_TM.shp"
Landcover = r"c:Users\projects\Scratch.gdb\Landcover"
Landcover = arcpy.sa.ExtractByMask(LandcoverData, AU, "INSIDE")
4
  • Suggest you look at the code samples for correct syntax?
    – Hornbydd
    Jan 18 at 23:01
  • 1
    I see a missing backslash in the Landcover path: c:Users
    – mikewatt
    Jan 18 at 23:47
  • Apologies the missing backslash is an error from me copying over the code! Jan 19 at 15:50
  • As far as I can tell the syntax is correct as that's what I used to create the code. I haven't included the save output line because I don't want to save as it's an intermediate file Jan 19 at 15:51

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.