AnsweredAssumed Answered

Error 010240 arcpy-numpy

Question asked by ivandorte on Apr 16, 2016
Latest reply on Apr 17, 2016 by curtvprice

I'm following this guide to extract pixels with certain rgb code (eg 255,0,0)  in a .tif raster using Anaconda 32bit:

RasterToNumPyArray—ArcPy Functions | ArcGIS for Desktop

But I receive this error:

 

 

os.chdir("C:\\Users\\ivn\\Desktop\\NumpArr")
filein = os.path.join(os.getcwd(),r'AR00199.tif')
fGDB = "fGDB.gdb"
if not os.path.exists(os.path.join(os.getcwd(),fGDB)):
 arcpy.CreateFileGDB_management(os.getcwd(),fGDB)
fileoutgdb = os.path.join(os.getcwd(),r"fGDB.gdb\blocco")
arcpy.env.overwriteOutput = True
arcpy.env.outputCoordinateSystem = filein
arcpy.env.cellSize = filein
arcpy.env.workspace = os.path.join(os.getcwd(),r"fGDB.gdb")
arcpy.env.scratchWorkspace = os.path.join(os.getcwd(),r"fGDB.gdb")
inRas = arcpy.Raster(filein)
b1 = arcpy.sa.Raster(r'AR00199.tif\Band_1')
b2 = arcpy.sa.Raster(r'AR00199.tif\Band_2')
b3 = arcpy.sa.Raster(r'AR00199.tif\Band_3')
blocksize = 512 
blockno = 0
for x in range(0,inRas.width,blocksize):  
    for y in range(0, inRas.height, blocksize): 
        blockno += 1
        mx = inRas.extent.XMin + x * inRas.meanCellWidth
        my = inRas.extent.YMin + y * inRas.meanCellHeight
        lx = min([x + blocksize, inRas.width])
        ly = min([y + blocksize, inRas.height])
        b1nr = arcpy.RasterToNumPyArray(b1,arcpy.Point(mx, my),lx-x, ly-y)       
        b2nr = arcpy.RasterToNumPyArray(b2,arcpy.Point(mx, my),lx-x, ly-y)
        b3nr = arcpy.RasterToNumPyArray(b3,arcpy.Point(mx, my),lx-x, ly-y)
        rgb = np.array([b1nr, b2nr,b3nr], np.uint8)
    
         #Operations on blocks.... 
        ....
        ....
        ....
        myRasterBlock = arcpy.NumPyArrayToRaster(output_array,\
        arcpy.Point(mx, my),inRas.meanCellWidth,inRas.meanCellHeight)
        filetemp = '_'.join([fileoutgdb,str(blockno)])
        myRasterBlock.save(filetemp) 

 

 

It save about 173 grids with blocksize = 512 and 73 whit blocksize = 1024 in gdb and then I receive the error... why?? Can someone help?

 

This is the result of the operation for a block:

Outcomes