AnsweredAssumed Answered

Nodata Value for Value > 255

Question asked by whuyp on May 21, 2018

Hi,

I tried to use map algebra to create raster based on the condition, the script looks like this:

###################

#Create  a raster from the netcdf file

arcpy.MakeNetCDFRasterLayer_md(inNetCDFFile, variable, XDimension, YDimension,
 outRasterLayer, bandDimmension, dimensionValues,  valueSelectionMethod)

#Create two constant for the True and false conditions

inTrueRaster = Int(1.0)
#inTrueRaster = 1000
inFalseConstant = Int(0.0)
#Set the threshold for 0.2
rainThreshold = 0.2

#create a new masking raster based on the threshold value
RasterCal = Con(Raster(outRasterLayer) >= rainThreshold, inTrueRaster, inFalseConstant)
#Raster with all 0 value
ZeroDayRaster = Con(predayRaster,inFalseConstant,inFalseConstant)

#Raster with all 1 value

PlusOneRaster = Con(predayRaster, inTrueRaster, inTrueRaster)

#resulting raster with conditional false
TrueResultRaster = predayRaster + PlusOneRaster

# raster based on the condition

raindayRaster = Con(RasterCal > 0, ZeroDayRaster, TrueResultRaster)

#Reproject and save the raster

outRaster = os.path.join(GridFolder,'RainDays', product + "_RainDays_p2.tif")
arcpy.ProjectRaster_management(raindayRaster, outRaster, Web_Mercator_prj,"NEAREST", "4763")

############################

However, I got an issue when the raster value > 255, the grid value was set to Nodata automatically, but I need the value bigger than 255 (260 or bigger), I specified the raster bit depth to 16 unsigned, however, the

script below:

raindayRaster = Con(RasterCal > 0, ZeroDayRaster, TrueResultRaster)

Always assign nodata to grid which is bigger than 255,

Has anyone experience this issue? Any idea/

Thanks,

Ping Yang(Peter)

Outcomes