1

I'm trying to save a raster after calculation in numpy array. Here is what I wrote:

rasterSM = arcpy.NumPyArrayToRaster(SM, lowerLeft, cellSize, value_to_nodata=nodata)
rasterSM2 = arcpy.DefineProjection_management(rasterSM, spatial_ref)
rasterSM2.save(SMOutputName)

But the error message says that 'Result' object has no attribute 'save', then out to save a raster from Numpy array?

Aaron
52k30 gold badges161 silver badges326 bronze badges
asked Jan 2, 2016 at 4:46
4
  • What does the variable SMOutputName look like? Commented Jan 2, 2016 at 4:53
  • SMOutputName = "Y:\\MODIS_Sep\\" + "SM" + str(partName)+ ".tif" and the partName is a number. Commented Jan 2, 2016 at 4:54
  • 1
    I believe the problem is that you are trying to save a non-raster object rasterSM2. Instead, try rasterSM.save(SMOutputName). Once that is complete then define the projection using arcpy.DefineProjection_management(SMOutputName, spatial_ref) Commented Jan 2, 2016 at 4:56
  • 1
    @Aaron Thank you Aaron! It worked! rasterSM = arcpy.NumPyArrayToRaster(SM, lowerLeft, cellSize, value_to_nodata=nodata) rasterSM.save(SMOutputName) arcpy.DefineProjection_management(SMOutputName, spatial_ref) Commented Jan 2, 2016 at 5:01

1 Answer 1

3

I believe the problem is that you are trying to save a non-raster object rasterSM2. Instead, try:

rasterSM.save(SMOutputName) 

Once that is complete, then define the projection using:

arcpy.DefineProjection_management(SMOutputName, spatial_ref)
answered Jan 2, 2016 at 5:03

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.