如何解决AttributeError: 'unicode' 对象没有属性 'strftime'
import arcpy,os
from arcpy.sa import *
arcpy.env.overwriteOutput = True
fc = r'E:\dada proj\DRAW OBJECTS\VIPPoints.mdb\Allfeat'
# Point feature class,needs to be in a file geodatabase (for the where clause to work)
output_folder = r'C:\GIS\data\testdata' # Where the rasters will be saved
date_field = 'date_' # field holding the dates (date type,not string)
value_fields = ['CO','O3','NO2'] # field with the values to interpolate
all_dates = list({i[0] for i in arcpy.da.SearchCursor(fc,date_field)}) # List all unique dates
for date in all_dates:
# Create a feature layer of each unique date
where = "{0}=date '{1}'".format(arcpy.AddFieldDelimiters(datasource=fc,field=date_field),date.strftime('%Y-%m-%d'))
arcpy.MakeFeatureLayer_management(in_features=fc,out_layer='lyr',where_clause=where)
# For each field interpolate. This is untested since I dont have spatial analyst
for fieldname in value_fields:
outIDW = Idw(in_point_features='lyr',z_field=fieldname,cell_size=10) #,{power},{search_radius},{in_barrier_polyline_features})
outIDW.save(os.path.join(output_folder,'{0}_{1}.tif'.format(fieldname,date.strftime('%Y%m%d'))))
运行时出错
AttributeError: 'unicode' object has no attribute 'strftime'
我的日期在表格和格式中:yyyy/mm/dd 感谢任何解决错误的建议
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。