I'm using a tool in ArcPy for Python 3 (ArcGIS Pro) which applies an operation to a raster file in GeoTIFF format.

condicion = '("{}"  - {}) / {}'.format(input_image,n,m)
arcpy.gp.RasterCalculator_sa(condicion, output_image)

Where n and m are doubles and input_image and output_image strings referring to the GeoTiff file.

It works fine but it changes the NODATA value from -3,40282306074E+38 (NODATA value used by ArcPy in Python2 and ArcMap) to -1.79769313486231571e+308 (nodata value used by ArcPy in Python3 and ArcGIS Pro).

But I want to preservate the previous NODATA value, I'm trying to use arcpy.SetRasterProperties_management tool. Is it possible to use it this way?

condicion = '("{}"  - {}) / {}'.format(input_image,n,m)
arcpy.gp.RasterCalculator_sa(condicion, output_image)
arcpy.SetRasterProperties_management(output_image, nodata='1 -3,40282306074E+38')

This code does not return any errors, but neither does the raster NODATA value change.

  • According to the documentation, that is the way to use it. Are you getting any error? – Marcelo Villa-Piñeros Jul 31 '19 at 13:32
  • I don't get any error, but the intended chage has no effect. According to the documentation, this tool takes a Raster Layer or a Mosaic Layer as input. The example described in it is similar to what I try to do: arcpy.SetRasterProperties_management("\\cpu\data\srtm.tif", "ELEVATION", "1 50 400 5 28" , "#" , "#") – gacero Aug 2 '19 at 7:35
  • What about the ',' in your '-3,40282306074E+38'? Does that need to be changed to a '.'? – toferkey Aug 13 '19 at 16:53

Your Answer

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

Browse other questions tagged or ask your own question.