Hi,

I'd like to get the first two numbers in the .txt file that is loaded as by NbrWeight (neighborhood object weights) for the focal statistics tool.

I want to use them to calculate the area of the rectangle that is the neighborhood.

How do I easily access the values?

Here is what I have so far:

inWeightFile = arcpy.GetParameterAsText(5)

if inWeightFile == '#' or not inWeightFile:

inWeightFile = "C:\\temp\\PPR\\Test\\bee_kernel_2_5km.txt" # provide a default value if unspecified

# Create the Neighborhood Object for the buffer

myNbrWeight = arcpy.sa.NbrWeight(inWeightFile)

# Get number of cells in the buffer

NbrCellsBuffer = 65 * 65 # XXX need to fix this. Should come from first two numbers in inWeightFile

# Process: Focal Statistics - within buffer calculate sum of f_rc1_H1 with exponential decay function and divide by number of cells in buffer

arcpy.AddMessage("Calculate proportional cover of high floral quality classes within buffer for first floral season")

f_rc_f_H1 = (arcpy.sa.FocalStatistics(f_rc1_H1, myNbrWeight, "SUM", "NODATA") * outConstRaster) / NbrCellsBuffer

Any help is greatly appreciated.

Best,

Amelie

The above opens the file and grabs the first line, strips off the newline ('\n') character and splits it into a list of two strings at the space then uses python list comprehension to convert the strings to integer values.