I am trying a convert a raster dataset [a simple 4 x 4] into a numpy array using RasterToNumPyArray. Here is my sample raster dataset:
RasterToNumPyArray however, returns zero for Null values:
inRaster = "Slope_NULL" # Create a Raster Object and get its lowerleft aRObject = arcpy.Raster(inRaster) lowerLeft = aRObject.extent.lowerLeft print aRObject.noDataValue # Create a numpy array of the Raster Object anArray = arcpy.RasterToNumPyArray(aRObject) print anArray
and I get:
I am wondering if there is a way that I could get None or NaN instead of zero in my array?
I know I can change the Nodata to a value using nodata_to_value, however, RasterToNumPyArray syntax is explaining that the default value is None, and it is important for me to have None and not zeros in my array.
How can I have None or NaN [I am not sure which one is better supported in numpy] in my array?