Trying to maintain spacial reference on newly created numpy array

المشرف العام

Administrator
طاقم الإدارة
I am trying to copy the values from raster into newly created array and then trying to save the array with same spatial reference as raster file

import arcpyimport numpyinRas = arcpy.GetParameterAsText(0)double_layer = arcpy.GetParameterAsText(1)num_layer = int(double_layer)output_path = arcpy.GetParameterAsText(2)# information on input rasterdsc = arcpy.Describe(inRas)sr = dsc.SpatialReferenceext = dsc.Extentll = arcpy.Point(ext.XMin,ext.YMin)arr = arcpy.RasterToNumPyArray(inRas, nodata_to_value=0)shape = arr.shapearcpy.AddMessage("image array created")freq = numpy.empty(shape=(1, shape[1], shape[2]))freq_numpy = numpy.uint8(freq)arcpy.AddMessage("frequency array created")#count = 1# check for the 46 layers# count is giving me total number of pixelsfor x in range(0, shape[1]): for y in range(0, shape[2]): freq = 0 for z in range(0, num_layer): # z is number of layer if arr[z][x][y] == 1: freq = freq + 1 freq_numpy[0][x][y] = freqarcpy.AddMessage("code finish file stored at"+ output_path)newRaster = arcpy.NumPyArrayToRaster(freq_numpy,ll,inRas.meanCellWdith,inRas.meanCellHeight)arcpy.DefineProjection_management(newRaster, sr)newRaster.save(output_path)ERROR:

Traceback (most recent call last): File "D:\PythonScripts\FrequencyBackup.py", line 66, in cellHeight = inRas.meanCellHeightAttributeError: 'unicode' object has no attribute 'meanCellHeight'

Failed to execute (Frequency).Failed at Thu Dec 17 16:20:53 2015 (Elapsed Time: 4.75 seconds)

while i try to access inRas.meanCellHeight in python concole of arcgis it allows meCan any one help with the solution



أكثر...
 
أعلى