Arcpy.sa NoData issue with saving TIFF

المشرف العام

Administrator
طاقم الإدارة
Similar to the poster here, I am attempting to convert numerical NoData values to actual NoData cells. The solution in the linked question doesn't work for me, however, as when I use the save method to save to TIFF the numerical values are reintroduced.

When I do this manually (using the GUI tools) I do not have the issue. When I use arcpy.gp.SetNull_sa (over arcpy.sa) I do not have the issue, but using the gp approach doesn't work on one of our team member's machines for some reason. I have not found much documentation on the gp appr, either.

I can save the outputs as GRID and export using the context menu because that tool allows you to supply a NoData value, but the Raster To Other Format (Conversion) tool doesn't give that option. It appears to work, regardless, but does not let you name the output (only the workspace), which means there's another step to add to the script (renaming). This solution seems too convoluted to be the right one, and also takes twice as long as the other methods.

So, what are methods for saving the output from an arcpy.sa tool in TIFF format with NoData intact?

Environments:

arcpy.env.compression = "NONE"arcpy.env.rasterStatistics = "STATISTICS 1 1"arcpy.env.resamplingMethod = "NEAREST"arcpy.env.snapRaster = inDEMarcpy.env.tileSize = "128 128"arcpy.env.pyramid = "PYRAMIDS -1 NEAREST DEFAULT 75 NO_SKIP"arcpy.env.extent = inDEMarcpy.env.nodata = "NONE"This does not work:

con_ras = arcpy.sa.Con(arcpy.sa.IsNull(outBreachrast),outBreachrast,inDEM,""""Value" = 0""")con_ras.save(tempDEM)null_ras = arcpy.sa.SetNull(arcpy.sa.IsNull(inDEM),tempDEM,""""Value" = 1""")null_ras.save(outDEM)This does (but not on everyone's computers):

arcpy.gp.IsNull_sa(inDEM, isnullDEM)arcpy.gp.SetNull_sa(isnullDEM, tempDEM, outDEM, """"Value" =1""")This also does, but does not let you specify file names:

con_ras = arcpy.sa.Con(arcpy.sa.IsNull(outBreachrast),outBreachrast,inDEM,""""Value" = 0""")con_ras.save(tempDEM)null_ras = arcpy.sa.SetNull(arcpy.sa.IsNull(inDEM),arcpy.sa.Con(arcpy.sa.IsNull(outBreachrast),outBreachrast,inDEM,""""Value" = 0"""),""""Value" = 1""")tiff_ras= arcpy.RasterToOtherFormat_conversion(null_ras, outDir, "TIFF")

أكثر...
 
أعلى