The code below takes a huge raster, and a set of point features. For each of them creates a circular buffer (100), then squares it, and then clips that part of the buffer. In doing so, we end up with a png image for each of the point locations.
The script works fine, the main problem, is that it adds each clipped feature to the workspace. These are around 35,000 points, so at about 1100, it just kills arcmap, and I have to restart the process from where it stopped (that is the reason there is an if, to check for 1107).
Is there a way to just do the clipping, without everything being loaded in the environment?
import arcpy import os image_name = "MyMosaicDataset2.tif" #has to be loaded in the env main_path = 'C:\Users\leon\Documents\Data\VCR_Data\Leon' workspace_name = 'Mars_Tartarus_Colles_Georefrencedg.mxd' arcpy.env.workspace = os.path.join(main_path, workspace_name) base_for_buffer = 'VRCs' buff_name = 'VRC_buff' output_buffer = os.path.join(main_path, buff_name+'.shp') output_sq_buffer = os.path.join(main_path, buff_name+'_sq'+'.shp') radius_buffer = '100 meters' arcpy.Buffer_analysis(base_for_buffer, output_buffer , radius_buffer, 'FULL', 'ROUND', 'NONE','','PLANAR') #This is to create the buffers arcpy.FeatureEnvelopeToPolygon_management(output_buffer, output_sq_buffer,"SINGLEPART") #This transforms the circular buffers into rectangular buffers rows = arcpy.SearchCursor(buff_name+'_sq')#here are the buffer polygons, and stored ina list #This is for clipping cnt=1 for row in rows: #go over the list if cnt >= 1107: feat = row.Shape name = 'vrcp_'+str(cnt) output_raster = os.path.join(main_path, name) arcpy.Clip_management(image_name, "#", output_raster+'.png',feat, "0", "ClippingGeometry") cnt+=1 enter code here