rioclaro

Loop to clip rasters with polygons and give name to clipped raster

Discussion created by rioclaro on Jan 10, 2018
Latest reply on Jan 12, 2018 by AHandelman_HSAC

Hello. 
I have 190 rasters and 190 polygons.
I need to clip each raster with it respective polygon
Rasters are identified as sm001.jpg to sm192.jpg
Polygons are identified as sm001_plg.shp to sm192.shp

In each iteration the raster clipped must be named as sm001.img ...sm192.jpg

 

With the below code I am doing the proccess manually

arcpy.Clip_management(in_raster="D:/ask/smimgs/sm001.jpg",
out_raster="D:/ask/smimgs_clips/sm001clp.img",
in_template_dataset="D:/ask/sm_plg/sm001_plg.shp",
nodata_value="256", clipping_geometry="NONE", maintain_clipping_extent="NO_MAINTAIN_EXTENT")

 

Could anyone help me to write the code in a loop?
Any idea is welcome
Thank you very much indeed

Outcomes