1

I've been trying to find the cell size, or height/width/mean, of a cell by utilizing arcpy in the Python Window in ArcGIS Pro version 2.3.3., I run the following code:

import arcpy
env = arcpy.env
env.workspace = "D:\Fall 2019\GEOG 625\pr\pen"
raster = "D:\Fall 2019\GEOG 625\pr\pen\LandsatHMB201707"
description = arcpy.Describe(raster)
arcpy.env.Describe("D:\Fall 2019\GEOG 625\pr\pen\LandsatHMB201707").meanCellHeight

I've looked into the raster properties here https://pro.arcgis.com/en/pro-app/arcpy/functions/raster-band-properties.htm

and the error code I get is:

AttributeError: DescribeData: Method meanCellWidth does not exist

2

You are calling Describe function again using arcpy.env.Describe which does not seem to be correct. Although you already used arcpy.Describe() which is the correct one. you did not use it.

Here is a working code, you can adjust your code based on it:

import arcpy
from arcpy import env
env.workspace = r"F:\Ahmad\Test\Landsat_Test"
raster = "TestClassClip.tif"
desc = arcpy.Describe(raster)
cellsize = 'Hight = {0}, Width = {1}'.format(desc.meanCellHeight,desc.meanCellWidth)
print (cellsize)

Output:

Hight = 30.0, Width = 30.0

enter image description here

  • Thank you for the feedback Ahmad, unfortunately it did not work. However I talked to a classmate and figured out what the problem was: ` import arcpy from arcpy import env env.workspace = r"D:\Fall 2019\GEOG 625\pr\pen\LandsatHMB201707" describe = arcpy.Describe("LandsatHMB201707.tif\Band_1") Cell_Size = describe.meanCellWidth print(Cell_Size) ` Was the correct code. Have to specify the specific band due to file having numerous bands. – Michael Breidert Sep 20 at 19:30
  • @MichaelBreidert You are welcome. Glad you you could solve the problem. – ahmadhanb Sep 20 at 19:59
0
import arcpy
from arcpy import env
env.workspace = r"D:\Fall 2019\GEOG 625\pr\pen\LandsatHMB201707"
describe = arcpy.Describe("LandsatHMB201707.tif\Band_1")
Cell_Size = describe.meanCellWidth
print(Cell_Size)

Figured it out with a classmate, thank you for the help Ahmed

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.