I have a fishnet and I want to make a script that sequentially uses each square of the fishnet as the output extent to clip a raster.
If I select a single square of the fishnet I can then clip the raster with the fishnet feature as the output extent and it clips to that single selected square. I now want to iterate this for each square.
The issue is this: If I copy the exact code that successfully did the clip I wanted and I execute this code in the Python window, it no longer clips to the extent of the single selected square but instead clips to the full extent of the fishnet feature. This means that if I try to iterate this using a for loop to select the desired fishnet square then clip the raster to that square then each time it clips it clips to the entire fishnet feature and not the selected square.
for n in range(1,100): x = str(n) arcpy.SelectLayerByAttribute_management(in_layer_or_view="Fishnet", selection_type="NEW_SELECTION", where_clause="ID = " + x) arcpy.Clip_management(in_raster="raster.tif", rectangle"", out_raster="clip_raster_” + x + ".tif", in_template_dataset="Fishnet", nodata_value="#", clipping_geometry="NONE", maintain_clipping_extent="NO_MAINTAIN_EXTENT")
Any way to fix this code so it only clips to the selected fishnet square and not to the entire fishnet feature?