I'm trying to reiterate though polygons of a shape file to extract seperate rasters through the function extractionbymask.
This is the code right now but it ends in the error code ER000732: Input Raster does not exist or is not supported. I ran this in the python window and can see that both inputs show up, but the output is empty.
I'm a beginner so I have probably missed something obvious but have been unable to figure out what.
# First import arcpython and set environment
import arcpy
import os
arcpy.env.workspace= "E:\\GIS_Work\\Python"
arcpy.env.overwriteOutput = True
from arcpy.sa import *
from arcpy import env
print("Environment set")
#Define variables
S_M_Map= Raster("SLUMFKKlassad.tif")
Zone = "Split.shp"
print ("Variables defined")
Check out license
arcpy.CheckOutExtension("Spatial")
#Create Iteration #Extract Raster to Polygon
i = 1
with arcpy.da.SearchCursor(Zone, 'Shape@') as cursor:
for row in cursor:
name = "Location"+str(i)
i = i+1
print (name)
outExtractByMask = ExtractByMask(S_M_Map, row)
outExtractByMask.save(name)
Code formatting ... the Community Version - Esri Community
to provide line numbers and proper indentation
The output files should be rasters but I suggest *.tif files
name = "Location"+str(i) +".tif"
and you can use row for the extraction you have to use the file... name
but you need a layer or raster not the shape so you will either have to make a feature layer or do a select by attribute to select on the object id field
Make Feature Layer (Data Management)—ArcGIS Pro | Documentation
not sure what you want to do in that regard
ExtractByMask(S_M_Map, zone)
Extract by Mask (Spatial Analyst)—ArcGIS Pro | Documentation