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).
1 Answer 1
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.
-
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 versionSWAT– SWAT2017年03月31日 12:04:59 +00:00Commented 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.Hornbydd– Hornbydd2017年04月01日 01:34:00 +00:00Commented Apr 1, 2017 at 1:34