# Getting subset of pixels of raster using ArcPy without Advanced license?

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.

• does it work? sorry for bad explanation. – alby Aug 19 '16 at 17:43

## 1 Answer

You can simply reshape it to 2-D. For instance:

`raster_numpy[0, 1:x_length-1].reshape(1, raster_numpy.shape - 2)`

Also, if you wish to take column 0 and the inner rows, you need to slice it differently. I believe this is what you're looking for:

`raster_numpy[1:-1, 0].reshape(raster_numpy.shape - 2, 1)`