Python Arcpy.description读取ENVI.dat时遇到的问题
这可能看起来很琐碎,但我似乎可以跟踪错误,而且我对Python非常陌生,尽管不熟悉编程。通过在互联网上阅读一段时间,我认为我的问题是.dat ENVI图像文件不是作为描述对象读取的。但我怎样才能让它被这样解读呢?我可能也需要它来读取标题信息,有什么解决方案吗 这是我的密码:Python Arcpy.description读取ENVI.dat时遇到的问题,python,raster,arcpy,envi,Python,Raster,Arcpy,Envi,这可能看起来很琐碎,但我似乎可以跟踪错误,而且我对Python非常陌生,尽管不熟悉编程。通过在互联网上阅读一段时间,我认为我的问题是.dat ENVI图像文件不是作为描述对象读取的。但我怎样才能让它被这样解读呢?我可能也需要它来读取标题信息,有什么解决方案吗 这是我的密码: import arcpy #make sure you run the python associated with ArcGIS import os filepath = 'filepath' filename = 'f
import arcpy #make sure you run the python associated with ArcGIS
import os
filepath = 'filepath'
filename = 'filename'
band_names = range(1,225)
# Path creation
in_folder = filepath + os.sep + 'ENVI'
out_folder = filepath + os.sep + 'GeoTIFF' # preferably an empty folder
# input multiband raster
in_ENVI = in_folder + filename '.dat'
in_raster = raster(in_ENVI)
index = 0
# get raster information specific to each band
desc = arcpy.Describe(in_raster)
################### THIS IS WHERE I GET THE ERROR ##################
Runtime error
Traceback (most recent call last):
File "<string>", line 23, in <module>
NameError: name 'raster' is not defined
################### SCRIPT TERMINATED ##############################
for band in desc.children:
print band
bandName = band.name
band_path = os.path.join(in_raster, bandName)
dest_path = os.path.join(out_folder, filename '_' + band_names(index) + '.tif')
arcpy.CopyRaster_management(band_path, dest_path, "", "", "", "NONE", "NONE", "")
index = index + 1
好的,所以我自己就知道了。这是我使用的代码。错误实际上不在arcpy.description中,而是在arcpy.CopyRaster\u管理中,因为我没有将band\u name[index]转换为字符串
dest_path = os.path.join(out_folder, filename + str(band_names[index]) + '.tif')