1

I have multiple raster, I am trying to remove Nodata value using Copy_raster option. Since I have multiple raster, I am running a ArcPy script, save the raster as same input name.

But that script, does not allow me to remove the nodata pixel,and

Script below:

import arcpy, os
from arcpy.sa import *
arcpy.env.overwriteOutput = True

arcpy.CheckOutExtension('Spatial')

arcpy.env.workspace = r"D:\Argicul\Maize\maize_Yield"

outFolder = r"Argicul\Maize\maize_Yield1"

list = arcpy.ListRasters()

for inRaster in list:
    localRaster = Raster(inRaster)
    outRaster = arcpy.CopyRaster_management( localRaster, nodata_value="0")
    outRaster.save(outFolder + "\\" + inRaster ) 
4
  • Try: How to change NoData cells to a value
    – Bera
    Commented Jun 14, 2019 at 11:06
  • Thanks, but i am not looking for that which link you sent me. I trying to run the copy raster tool on ArcPy script.
    – SWAT
    Commented Jun 14, 2019 at 11:15
  • This command worked for me, changing the nodata value to -999: arcpy.CopyRaster_management(r"C:\scratch\ppp.tif",r"C:\scratch\ppp2.tif",nodata_value = -999)
    – Hornbydd
    Commented Jun 14, 2019 at 11:55
  • Thanks, I have multiple raster, how to define that multiple raster list in the functions.
    – SWAT
    Commented Jun 14, 2019 at 12:00

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.