I am looking for a good solution to get a particular subset of raster pixels. For example:
- I have raster 5x5
- I need to clip:
--column = 1
--row between 1 and 5
What will be the best method?
I was trying to get results using NumPy array by slicing it and exporting it back to raster.
I am wondering if there is much better way of doing it.
Here is my code. The problem is - I cannot export my numpy array slice to raster, because it is a 1 dimentional array.
import arcpy, numpy arcpy.env.overwriteOutput = True raster_path = r'D:\raster.tif' raster = arcpy.Raster(raster_path) lowerLeft = arcpy.Point(raster.extent.XMin, raster.extent.YMin) raster_numpy = arcpy.RasterToNumPyArray(friction_raster_buffered_path, lowerLeft) x_length = raster_numpy.shape print raster_numpy [0,1:x_length-1] arcpy.NumPyArrayToRaster(raster_numpy [0,1:x_length-1], lowerLeft, raster.meanCellHeight).save(r'd:\rstrLC.tif')
Error: ValueError: Argument in_array: A two or three dimensional NumPy array is required.