0

I have a series of raster files (tif) that extracted using a particular shapefile.
However, the output files became much larger (from 2 MB to 200MB). The NoData is now equivalent to pixel value of 255 instead of 0 (maybe this is the reason).

Is there a way to specify it through this code?

 import arcpy
 from arcpy import env
 from arcpy.sa import *
 arcpy.CheckOutExtension("Spatial")
 env.overwriteOutput = True

 #Set the current workspace
 env.workspace = ("C:\Users\Brent\Documents\JO_GIS_Analyst and PA")

 #This is for extracting the forest areas of hansen percent treecover
 for raster in arcpy.ListRasters("lossyear*", "TIF"):
     print raster #checking the presence of raster
     outputRasterExtractbyMask = ExtractByMask(raster, "NAMRIA.shp")
     outputRasterExtractbyMask_Name = "forest_only"+raster
     outputRasterExtractbyMask.save(outputRasterExtractbyMask_Name)
2

The reason why your dataset is larger is not the value of the no data : storing a zero takes the same memory as storing 255. In order to solve your problem, you should make sure that your data is compressed.

arcpy.env.compression = "LZ77"

and to answer your question,

arcpy.env.nodata = "MINIMUM"

will set your output to, I cite,

MINIMUM—The minimum value in the output data range will be used as your NoData value.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.