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?

  • What does the variable SMOutputName look like? – Aaron Jan 2 '16 at 4:53
  • SMOutputName = "Y:\\MODIS_Sep\\" + "SM" + str(partName)+ ".tif" and the partName is a number. – Yitongjj Jan 2 '16 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) – Aaron Jan 2 '16 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) – Yitongjj Jan 2 '16 at 5:01
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)

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.