class Fields():
def get(self):
logFilePath = ''
print('执行获取图层字段接口')
print('开始')
sde_file = 'D:/127.0.0.1.sde'
# sde_file = 'D:/data.gdb'
# sde_file = 'D:/data.mdb'
layername = 'DLTB'
data_layer = sde_file + "/" + layername
if not arcpy.Exists(data_layer):
self.write('[{"msg":"data_layer<' + data_layer + '> is not Exists."}]')
m_cfg.writelog(logFilePath, 'data_layer<' + data_layer + '> is not Exists.')
return
results = []
fields = arcpy.ListFields(data_layer, field_type='All')
for field in fields:
if not field.type in ['OID'] and not field.name in ['SHAPE.AREA', 'SHAPE.LEN', 'SHAPE_Area', 'SHAPE_Length',
'SHAPE_AREA', 'SHAPE_LEN','SHAPE']:
results.append({
"name": field.name,
"aliasName": field.aliasName,
"baseName":field.baseName,
"domain":field.domain,
"editable":field.editable,
"isNullable":field.isNullable,
"length":field.length,
"scale": field.scale,
"precision": field.precision,
"required":field.required,
"type": field.type
})
self.write(json.dumps(results))
print('图层字段获取成功。')
print( '结束')
【基于arcpy获取图层字段】
最新推荐文章于 2023-05-18 11:39:20 发布