Python 调用 NetCDF 文件时出现错误 000732
ERROR 000732 in Python calling for NetCDF file
执行以下代码时,我不断收到错误消息,而且我无法修复它。任何想法可能是错的?我试图将文件名更改为更简单的文件名,但没有帮助。 NetCDF数据来自TRMM
import arcpy
import os
dir_name = 'D:\Data'
# Set local variables
inNetCDFFile = "D:\DataB43.20090201.7A.HDF.nc"
variable = "precipitation"
XDimension = "nlon"
YDimension = "nlat"
outRasterLayer = "D:\Data\test"
bandDimmension = ""
dimensionValues = ""
valueSelectionMethod = ""
# Execute MakeNetCDFRasterLayer
arcpy.MakeNetCDFRasterLayer_md(inNetCDFFile, variable, XDimension, YDimension,
outRasterLayer, bandDimmension, dimensionValues,
valueSelectionMethod)
错误:
Traceback (most recent call last):
File "D:\Python27\ArcGIS10.2\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py", line 326, in RunScript
exec codeObject in __main__.__dict__
File "D:\Google Drive\Gates Project\Data\Climate\TRMM\Python\TRMMNetCDFtoRaster.py", line 19, in <module>
valueSelectionMethod)
File "D:\Program Files (x86)\ArcGIS\Desktop10.2\arcpy\arcpy\md.py", line 171, in MakeNetCDFRasterLayer
raise e
ExecuteError: Failed to execute. Parameters are not valid.
ERROR 000732: Input netCDF File: Dataset D:\DataB43.20090201.7A.HDF.nc does not exist or is not supported
Failed to execute (MakeNetCDFRasterLayer).
我不熟悉 arcpy
,但 example 使用正斜杠,而不是反斜杠。我会试试
inNetCDFFile = "D:/Data/3B43.20090201.7A.HDF.nc"
显然您正在尝试加载错误的文件路径:
ERROR 000732: Input netCDF File: Dataset D:\DataB43.20090201.7A.HDF.nc does not exist or is not supported
如果您在 Windows 使用:
inNetCDFFile = "D:\Data\3B43.20090201.7A.HDF.nc"
或
inNetCDFFile = r"D:\DataB43.20090201.7A.HDF.nc"
查理
感谢您的帮助,我已经设法制作了一个不错的脚本,它从目录中获取所有 NetCDF 文件并将它们转换为栅格,所以我将在这里 post 它 - 其他人可能会发现它有用! (专门针对TRMM降雨数据)
import arcpy
import os
dir_name = 'D:\Data'
# Set local variables
variable = "precipitation"
XDimension = "nlon"
YDimension = "nlat"
bandDimmension = ""
dimensionValues = ""
valueSelectionMethod = "BY_VALUE"
# Loop that converts NetCDF files from directory and converts to .img rasters:
dir_name = 'D:\Data'
for filename in os.listdir(dir_name):
if not filename.endswith(".nc"): continue
full_path = os.path.join(dir_name, filename)
outRaster = '%s.img' % (full_path,)
fileroot = filename[0:(len(filename)-10)]
outRasterLayer = dir_name + "\" + fileroot
arcpy.MakeNetCDFRasterLayer_md(full_path, variable, XDimension, YDimension,
outRasterLayer, bandDimmension, dimensionValues,
valueSelectionMethod)
arcpy.CopyRaster_management(outRasterLayer,outRaster)
瞧!
执行以下代码时,我不断收到错误消息,而且我无法修复它。任何想法可能是错的?我试图将文件名更改为更简单的文件名,但没有帮助。 NetCDF数据来自TRMM
import arcpy
import os
dir_name = 'D:\Data'
# Set local variables
inNetCDFFile = "D:\DataB43.20090201.7A.HDF.nc"
variable = "precipitation"
XDimension = "nlon"
YDimension = "nlat"
outRasterLayer = "D:\Data\test"
bandDimmension = ""
dimensionValues = ""
valueSelectionMethod = ""
# Execute MakeNetCDFRasterLayer
arcpy.MakeNetCDFRasterLayer_md(inNetCDFFile, variable, XDimension, YDimension,
outRasterLayer, bandDimmension, dimensionValues,
valueSelectionMethod)
错误:
Traceback (most recent call last):
File "D:\Python27\ArcGIS10.2\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py", line 326, in RunScript
exec codeObject in __main__.__dict__
File "D:\Google Drive\Gates Project\Data\Climate\TRMM\Python\TRMMNetCDFtoRaster.py", line 19, in <module>
valueSelectionMethod)
File "D:\Program Files (x86)\ArcGIS\Desktop10.2\arcpy\arcpy\md.py", line 171, in MakeNetCDFRasterLayer
raise e
ExecuteError: Failed to execute. Parameters are not valid.
ERROR 000732: Input netCDF File: Dataset D:\DataB43.20090201.7A.HDF.nc does not exist or is not supported
Failed to execute (MakeNetCDFRasterLayer).
我不熟悉 arcpy
,但 example 使用正斜杠,而不是反斜杠。我会试试
inNetCDFFile = "D:/Data/3B43.20090201.7A.HDF.nc"
显然您正在尝试加载错误的文件路径:
ERROR 000732: Input netCDF File: Dataset D:\DataB43.20090201.7A.HDF.nc does not exist or is not supported
如果您在 Windows 使用:
inNetCDFFile = "D:\Data\3B43.20090201.7A.HDF.nc"
或
inNetCDFFile = r"D:\DataB43.20090201.7A.HDF.nc"
查理
感谢您的帮助,我已经设法制作了一个不错的脚本,它从目录中获取所有 NetCDF 文件并将它们转换为栅格,所以我将在这里 post 它 - 其他人可能会发现它有用! (专门针对TRMM降雨数据)
import arcpy
import os
dir_name = 'D:\Data'
# Set local variables
variable = "precipitation"
XDimension = "nlon"
YDimension = "nlat"
bandDimmension = ""
dimensionValues = ""
valueSelectionMethod = "BY_VALUE"
# Loop that converts NetCDF files from directory and converts to .img rasters:
dir_name = 'D:\Data'
for filename in os.listdir(dir_name):
if not filename.endswith(".nc"): continue
full_path = os.path.join(dir_name, filename)
outRaster = '%s.img' % (full_path,)
fileroot = filename[0:(len(filename)-10)]
outRasterLayer = dir_name + "\" + fileroot
arcpy.MakeNetCDFRasterLayer_md(full_path, variable, XDimension, YDimension,
outRasterLayer, bandDimmension, dimensionValues,
valueSelectionMethod)
arcpy.CopyRaster_management(outRasterLayer,outRaster)
瞧!