I'm working in extracting smaller rasters from a bigger one (yellow). I'm using only python, some numpy maybe. I succesfully extracted a patch from a big raster, secuentially, by moving windows. So I ended up with several small rasters, 'quilted'/patching the bigger one. The code works for the first column of patches(red colored) (See graph, sample point 'A'), where the extracted raster and the source raster has the same value at any given cell (extracted raster in red means they match perfectly the source raster). However, all the patches in gray are off by one cell! See the values at sample points 'B' and 'C'. The right value in the patched raster is in the cell besides. And this displacement is kept to all the patches, except the first column. Odd that some rasters are ok and some not. What is wrong with my code?
for rows in range (0,8): for columns in range (0,10): 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) ) numpy_array = arcpy.RasterToNumPyArray(large_raster, small_raster_lower_left, window_size, window_size, nodata_to_value = -99999 ) 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) raster_counter += 1 small_raster_name = "small_dem_" + str(raster_counter) +"_c" + str(columns) + "_r" + str(rows) small_raster.save(small_raster_name) del numpy_array del small_raster except: del numpy_array del small_raster