2

I am trying to get raster properties using a Mask file for pixels that fall within mask, script will calculate that area statistics only.

Below is my script I am working on, but its showing an error

import arcpy
arcpy.env.workspace = r"D:\Annomaly_SPEI_12"
Mask = r"D:\Agro_Zone\Zone-1.shp"
rasterList = arcpy.ListRasters()
for raster in rasterList:
 rasterObj = arcpy.Raster(raster)
 print raster
 bands = arcpy.GetRasterProperties_management(Mask ,raster, "MEAN")
 print "MEAN VALUE: %s" %bands

Error Msg:

Property type: The input is not within the defined domain.
The value is not a member of MAXIMUM | MINIMUM | MEAN | STD | TOP | LEFT | RIGHT | BOTTOM | CELLSIZEX | CELLSIZEY | VALUETYPE | COLUMNCOUNT | ROWCOUNT | BANDCOUNT | ALLNODATA | ANYNODATA | SENSORNAME | PRODUCTNAME | ACQUSITIONDATE | SOURCETYPE | CLOUDCOVER | SUNAZIMUTH | SUNELEVATION | SENSORAZIMUTH | SENSORELEVATION | OFFNADIR | WAVELENGTH.
Failed to execute (GetRasterProperties).
Hornbydd
44.9k5 gold badges42 silver badges84 bronze badges
asked Mar 31, 2017 at 11:36

1 Answer 1

2

I am assuming that the 10.5 documentation reflects that of 10.3 where the syntax for this tool is:

 GetRasterProperties_management (in_raster, {property_type}, {band_index})

For property_type (the second parameter), a value from MAXIMUM | MINIMUM | MEAN | STD | TOP | LEFT | RIGHT | BOTTOM | CELLSIZEX | CELLSIZEY | VALUETYPE | COLUMNCOUNT | ROWCOUNT | BANDCOUNT | ALLNODATA | ANYNODATA | SENSORNAME | PRODUCTNAME | ACQUSITIONDATE | SOURCETYPE | CLOUDCOVER | SUNAZIMUTH | SUNELEVATION | SENSORAZIMUTH | SENSORELEVATION | OFFNADIR | WAVELENGTH is expected.

You have provided a Raster object from rasterList instead.

Once you have addressed this I think you should look at the Mask environment. If GetRasterProperties honors that then you should have your solution.

answered Mar 31, 2017 at 12:00
2
  • PolyGeo, thank you. My query is how to assign a mask file. if i removed mask statement from my script then my script working fine. But i want to execute a mask file to get properties of raster for certain area. i am using Arc GIS 10.3 version Commented Mar 31, 2017 at 12:04
  • 1
    @SWAT it's what Polygeo says you need to set the ENVIRONMENT setting of arcpy and set the Mask, his link shows you how to do that. Commented Apr 1, 2017 at 1:34

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.