0

I am trying to standardise a raster file which I have reprojected and intend to combine with multiple other rasters. I create a raster object in order to do this, but when I use the variable for this raster object in the subsequent equation I get the error message:

AttributeError: 'Raster' object has no attribute 'min'

Is this an issue with the file or is this an error I made further back in the code?

Here is my script, all necessary modules were previously imported:

if raster == "ROS.tif": 
    ros_BNG = "ROS".strip(".tif") + "_BNG.tif"
    arcpy.management.ProjectRaster(raster, ros_BNG, BNG)
    print("Reprojected " + raster)
    ros1 = Raster(ros_BNG)
    ros_std = (ros1 - ros1.min())/(ros1.max()- ros1.min())
    print("Standardised " + ros_BNG + " into " + ros_std)

1 Answer 1

1

The error is happening because you are making up methods that do not exist for the object in question. You should always refer to the help file when coding and if you look at the page for the Raster object do you see a min() or max() method...?

The Raster object has minimum and maximum properties:

ros_std = (ros1 - ros1.minimum)/(ros1.maximum - ros1.minimum)
1
  • Thank you, this clarified what the issue was and I eventually found where I was going wrong
    – Mkn
    May 25, 2022 at 14:19

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.