文章目录
一、功能介绍二、脚本代码三、工具参数四、工具界面
一、功能介绍
二、脚本代码
import os
import arcpy
import time
in_path
= arcpy
.GetParameterAsText
(0)
out_path
= arcpy
.GetParameterAsText
(1)
subdataset_index
= arcpy
.GetParameterAsText
(2)
suffix
= arcpy
.GetParameterAsText
(3)
arcpy
.env
.overwriteOutput
= 1
arcpy
.CheckOutExtension
("Spatial")
arcpy
.env
.workspace
= in_path
arcpy
.env
.scratchWorkspace
= in_path
hdfList
= arcpy
.ListRasters
('*', 'HDF')
nums
= len(hdfList
)
num
= 1
if not os
.path
.exists
(out_path
):
os
.makedirs
(out_path
)
for hdf
in hdfList
:
s
= time
.time
()
raster_name
= "{0}{1}{2}.{3}.tif".format(out_path
, os
.sep
, '.'.join
(hdf
.split
('.')[:3]), suffix
)
try:
data1
= arcpy
.ExtractSubDataset_management
(hdf
, raster_name
, subdataset_index
)
e
= time
.time
()
arcpy
.AddMessage
("{0}/{1} | {2} Completed, time used {3}s".format(num
, nums
, hdf
, e
-s
))
except:
arcpy
.AddMessage
("{0}/{1} | {2} Errored".format(num
, nums
, hdf
))
num
+= 1
三、工具参数
四、工具界面
转载请注明原文地址:https://tech.qufami.com/read-2734.html