I have a .tif
raster file which contains integer values at 1, 2, 3, 4 and 5. Importing this file into ArcMap also shows a number of cells with Nodata
value where the above classes are not present.
I was able to convert a tile from this .tif
file into a numpy array using the Arcpy documentation. I basically ran the following code
point = arcpy.Point(XCoord, YCoord)
test = arcpy.RasterToNumpyArray(RasterFileName, point, 10,10)
Where XCoord and YCoord are specifically selected to be in an area where all the returned raster values should be Nodata (according to ArcMap). Instead, I get the following output when I print out test
:
array([[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0]])
Why are these not the values corresponding to ArcMap?. For another set of coordinates in the region where there is data I get the following:
array([[2, 3, 2, 1, 2, 2, 2, 1, 1, 2],
[3, 3, 2, 1, 2, 2, 2, 1, 2, 2],
[3, 2, 2, 2, 2, 2, 2, 2, 3, 4],
[3, 2, 2, 3, 2, 3, 3, 3, 3, 4],
[2, 2, 3, 3, 2, 2, 3, 2, 2, 2],
[1, 3, 3, 3, 2, 2, 2, 1, 1, 2],
[1, 2, 2, 2, 2, 2, 2, 2, 1, 2],
[1, 2, 2, 2, 2, 2, 3, 3, 2, 2],
[1, 1, 1, 1, 1, 2, 4, 4, 2, 2],
[1, 1, 1, 1, 1, 2, 3, 3, 3, 3]])
This corresponds to the ArcMap information in that tile. Therefore I am sure that the raster is converting correctly.
How does ArcMap differentiate between NoDATA and 0 valued raster cells when in numpy NoDATA values are not allowed? Is the returned numpy array the actual data or is it simply a higher level representation of something else?