1

The following python script is working:

import arcpy
from arcpy import env

env.workspace = 'C:/Users/Matthew/Desktop/ARC_processing'

file_path = 'C:/Users/Matthew/Desktop/ARC_processing/MERRA_test_file_0_T.tif'

print(arcpy.CheckOutExtension("Spatial"))

arcpy.Plus_3d(file_path + '/Band_2', file_path + '/Band_3', 'added_bands_4.tif')

print(arcpy.CheckInExtension("Spatial"))

But when I replace the arcpy.Plus_3d . . . command with the following:

(arcpy.Raster(file_path + '/Band_2') + arcpy.Raster(file_path + '/Band_3')).save('added_bands_4.tif')

I get the error message:

Process finished with exit code -1073741819 (0xC0000005)

I get the same error message when I use other Map Algebra tools that are unique to the Spatial Analyst package (as opposed to also being available from the 3D analyst package, as Plus_3D() is).

Does anyone have any ideas why this might be happening and how to fix it?

I'm using ArcGIS Desktop 10.5.1.

1

The comment by FelixIP to my original question turned out to be the issue. It turns out that bands need to be turned into raster layers before those raster layers can be used in Spatial Analyst tools. I used the following command to accomplish this:

arcpy.MakeRasterLayer_management(file_path, 'band_2_layer', '', '', '1')

Then the Spatial Analysis commands work fine on the raster layers.

I hope this can help someone else, too!

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.