for rows in range (0,4):
for columns in range (0,5):
arcpy.AddMessage('> Attempt to extract raster [row]-[col]: [' + str(rows)+ ']-['+str(columns)+']...')
try:
small_raster_lower_left = arcpy.Point(large_raster_extent.XMin + (columns * window_size * large_raster_cellsize_X),
large_raster_extent.YMin + (rows * window_size * large_raster_cellsize_Y)
)
arcpy.AddMessage('> Raster to Numpy...')
numpy_array = arcpy.RasterToNumPyArray(large_raster,
small_raster_lower_left,
window_size,
window_size,
nodata_to_value=-99999
)
arcpy.AddMessage('> small raster coordinates. X: {0}, Y: {1}'.format(small_raster_lower_left.X,small_raster_lower_left.Y))
arcpy.AddMessage('> Numpy to raster...')
small_raster = arcpy.NumPyArrayToRaster(numpy_array,
small_raster_lower_left,
large_raster_cellsize_X,
large_raster_cellsize_Y,
value_to_nodata = -99999
)
arcpy.DefineProjection_management(small_raster, large_raster_spatial_ref)
small_raster_name = "small_dem_" + str(columns+rows*10)
arcpy.AddMessage('> Success! Saving raster: ' + small_raster_name + '...')
small_raster.save(small_raster_name)
del numpy_array
del small_raster
except:
arcpy.AddMessage('> Fault! Trying next window...')
del numpy_array
del small_raster
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user