2

I have been trying to convert a numpy array back to raster after doing some calculation on it and i keep running into errors. Basically I am trying to find flooded areas below a certain sea level eg 2 meters. Here is my code :

import arcpy ,os ,sys
import numpy as np

#conditioning the raster data   
outputRaster = Con(inRas1>=0 ,inRas1,1)
outputRaster.save(outputgdb + rasterName)


#clip the raster layer to study area
clipppedRaster = arcpy.Clip_management(outputRaster,"#",clipRaster,inputFeature,"#","ClippingGeometry","MAINTAIN_EXTENT")
#clippedRaster.save(outputgdb+ outputclip)

#convert raster to numpy array
num_array = arcpy.RasterToNumPyArray(clipRaster,nodata_to_value=0)


floodedAreas = num_array[np.where(num_array <= 2)]
arcpy.AddMessage(np.array(floodedAreas))
rasterflood = arcpy.NumPyArrayToRaster(floodedAreas,x_cell_size=1)
floodedAreas.save (outputgdb + "numpyarray1")

rasterflood = arcpy.NumPyArrayToRaster(floodedAreas,x_cell_size=1)
rasterflood.save(str(floodedArea))

arcpy.AddMessage(np.min(num_array))

But i keep running into the following error:

Traceback (most recent call last):
  File "C:\Python27\dealingwithraster.py", line 57, in <module>
    rasterflood = arcpy.NumPyArrayToRaster(floodedAreas,x_cell_size=1)
  File "c:\program files (x86)\arcgis\desktop10.4\arcpy\arcpy\__init__.py", line 2299, in NumPyArrayToRaster
    return _NumPyArrayToRaster(*args, **kwargs)
ValueError: Argument in_array: A two or three dimensional NumPy array is required.

What am I doing wrong here?

3