Esempio n. 1
0
def searchFzh(targetpath):
    """获取所有图斑中的fzh和bhlx,如果图斑图层不存在fzh和bhlx,则创建字段"""

    fzhlist = []
    targetValueDict = {}

    datas = []
    searchFields = ["TSTYBM", "bhlx", "fzh"]
    tempFields = ["TSTYBM", "bhlx", "fzh"]

    arcpyDeal.ensureFields(targetpath, searchFields)

    sql_clause = (None, "ORDER BY fzh")

    arcpyDeal.createTempDatas(searchFields,
                              tempFields,
                              targetpath,
                              datas,
                              sql_clause=sql_clause)

    for data in datas:

        fzh = dealNone.dealNoneAndBlank(data['fzh'])
        bhlx = dealNone.dealNoneAndBlank(data['bhlx'])

        if fzh != "":
            fzhlist.append(int(fzh))

        targetValueDict[data['TSTYBM']] = {"bhlx": bhlx, "fzh": fzh}

    fzhlist.sort()

    return fzhlist, targetValueDict
Esempio n. 2
0
def checkdatas(dccgtb):

    datas = []
    newdatas = {}
    searchFields = [
        "objectid", "TBYBH", "WYM", "BHLX", "DLBM", "ZZSXDM", "ZZSXMC",
        "TBXHDM", "TBXHMC", "GDLXMC"
    ]
    tempFields = [
        "objectid", "TBYBH", "WYM", "BHLX", "DLBM", "ZZSXDM", "ZZSXMC",
        "TBXHDM", "TBXHMC", "GDLXMC"
    ]

    arcpyDeal.createTempDatas(searchFields, tempFields, dccgtb, datas)

    for data in datas:

        data = checkTBYBHAndTBWYM(data)

        data = check1234(data)

        newdatas[data["objectid"]] = data

        arcpy.SetProgressorPosition()

    return newdatas
Esempio n. 3
0
def searchFzh(targetpath):
    """获取所有图斑中的unionfzh,如果图斑图层不存在unionfzhfzh,则创建字段"""

    unionfzhlist = []
    targetValueDict = {}

    datas = []
    searchFields = ["TSTYBM", "unionfzh"]
    tempFields = ["TSTYBM","unionfzh"]

    arcpyDeal.ensureFields(targetpath,searchFields)

    sql_clause = (None,"ORDER BY unionfzh")

    arcpyDeal.createTempDatas(searchFields,tempFields,targetpath,datas,sql_clause = sql_clause)

    for data in datas:
        
        unionfzh = dealNone.dealNoneAndBlank(data['unionfzh'])
        
        if unionfzh != "":
            unionfzhlist.append(int(unionfzh))

        targetValueDict[data['TSTYBM']] = {"unionfzh":unionfzh}

    unionfzhlist.sort()

    return unionfzhlist,targetValueDict
Esempio n. 4
0
def collectWJZTB(targetpath, photopath):
    """关联图斑和照片点图层,得到关联数据"""

    baseName1 = arcpy.Describe(targetpath).baseName
    baseName2 = arcpy.Describe(photopath).baseName

    arcpy.AddMessage("6_7_创建临时图层")

    arcpy.MakeFeatureLayer_management(targetpath, baseName1)
    arcpy.MakeFeatureLayer_management(photopath, baseName2)

    arcpy.AddMessage("6_7_图层关联")

    arcpy.AddJoin_management(baseName1, "TSTYBM", baseName2, "TSTYBM")

    where_clause = u" exp_tblx = '一般核查图斑' and ZZJZTB = '0' and exp_tbxhdm = '' and exp_wjzlx = '' and %s.TSTYBM is null" % (
        baseName2)

    datas = []
    tempFields = [
        "TSTYBM", "exp_sjdlbm", "exp_czcsxm", "exp_dlbm", "exp_gdzzsxdm",
        "exp_gdlx", "CZCSXM"
    ]
    searchFields = [baseName1 + "." + f for f in tempFields]

    arcpyDeal.createTempDatas(searchFields,
                              tempFields,
                              baseName1,
                              datas,
                              where_clause=where_clause)

    return datas
Esempio n. 5
0
def searchALL(targetpath):
    """获取所有图斑中的exp_bsm,fzh和bhlx,如果图斑图层不存在fzh和bhlx,则创建字段"""

    datas = []
    fzhlist = []
    targetValueDict = {}

    searchFields = ["exp_tbwym", 'fzh']
    tempFields = ["exp_tbwym", 'fzh']

    arcpyDeal.ensureFields(targetpath, searchFields)

    arcpyDeal.createTempDatas(searchFields, tempFields, targetpath, datas)

    for data in datas:

        fzh = dealNone.dealNoneAndBlank(data['fzh'])

        if fzh != "":

            if int(fzh) not in fzhlist:

                fzhlist.append(int(fzh))

        targetValueDict[data['exp_tbwym']] = {"fzh": fzh}

    fzhlist.sort()

    return fzhlist, targetValueDict
Esempio n. 6
0
def collectWJZLX(dccgtb):

    datas = []
    searchFields = ['TBYBH', 'WJZLX', 'SHAPE@X', 'SHAPE@Y']
    tempFields = ['TBYBH', 'WJZLX', 'SHAPE@X', 'SHAPE@Y']

    where_clause = " WJZLX <> ''"

    arcpyDeal.createTempDatas(searchFields,
                              tempFields,
                              dccgtb,
                              datas,
                              where_clause=where_clause)

    return datas
Esempio n. 7
0
def searchLinkTBS(targetpath):
    """查找拥有LINKTBS的图斑,并返回数据列表"""

    where_clause = "LINKTBS <> '' and LINKTBS is not null  "

    tempTargerPah = "tempLinkTBS"
    datas = []
    searchFields = ["TSTYBM",'LINKTBS','unionfzh']
    tempFields = ["TSTYBM",'linktbs','unionfzh']

    arcpyDeal.ensureFields(targetpath,searchFields)

    arcpyDeal.createTempDatas(searchFields,tempFields,targetpath,datas,where_clause = where_clause)

    arcpy.Delete_management(tempTargerPah)
    
    arcpy.AddMessage("7_共有%s个图斑存在LINKTBS"%(len(datas)))

    return datas
Esempio n. 8
0
def join(dccgtb, sourcePath):
    """关联调查成果图斑和照片点图层,得到关联数据"""

    baseName1 = arcpy.Describe(sourcePath).baseName
    baseName2 = arcpy.Describe(dccgtb).baseName

    arcpy.AddMessage("22_创建临时图层")

    arcpy.MakeFeatureLayer_management(sourcePath, baseName1)
    arcpy.MakeFeatureLayer_management(dccgtb, baseName2)

    arcpy.AddMessage("22_图层关联")

    arcpy.AddJoin_management(baseName1, "TSTYBM", baseName2, "WYM")

    where_clause = " %s.WYM is not null and %s.WJZLX = ''" % (baseName2,
                                                              baseName2)

    datas = []
    tempFields = ['CJRQ', 'CJR', 'FWJ', 'QCJ', 'FYJ', 'FJLX', 'MC']
    searchFields = [baseName1 + "." + f for f in tempFields]

    tempFields1 = ['SHAPE@X', 'SHAPE@Y', 'SHAPE@']
    searchFields1 = ['SHAPE@X', 'SHAPE@Y', 'SHAPE@']

    tempFields2 = ['TBYBH', 'WYM']
    searchFields2 = [baseName2 + "." + f for f in tempFields2]

    tempFields.extend(tempFields1)
    tempFields.extend(tempFields2)
    searchFields.extend(searchFields1)
    searchFields.extend(searchFields2)

    arcpy.AddMessage("22_照片点数据获取")

    arcpyDeal.createTempDatas(searchFields,
                              tempFields,
                              baseName1,
                              datas,
                              where_clause=where_clause)

    return datas
Esempio n. 9
0
def collecteFzh(targetpath, targetdatas, fzhlist, targetValueDict):
    """收集分组和变化类型"""

    linktbsLack = []

    mergeFzhList = {}

    for i in range(len(targetdatas)):

        targetdata = targetdatas[i]

        targettstybm1 = dealNone.dealNoneAndBlank(targetdata['TSTYBM'])
        targetlinktbs1 = dealNone.dealNoneAndBlank(targetdata['linktbs'])
        targetbhlx1 = dealNone.dealNoneAndBlank(targetdata['bhlx'])

        #分析存在LINKTBS的图斑的变化类型
        targetNewBhlx1 = BhlxRules(targetbhlx1)

        targetfzh1 = ""
        if targettstybm1 in targetValueDict:

            targetfzh1 = targetValueDict[targettstybm1]['fzh']

        targetValueDict[targettstybm1]['bhlx'] = targetNewBhlx1

        #查找LINKTBS对应图斑数据

        where_clause = "bsm = '%s' and TSTYBM <> '%s'" % (targetlinktbs1,
                                                          targettstybm1)

        targetdatas2 = []
        searchFields = ["TSTYBM", 'bhlx']
        tempFields = ["TSTYBM", 'bhlx']

        arcpyDeal.createTempDatas(searchFields,
                                  tempFields,
                                  targetpath,
                                  targetdatas2,
                                  where_clause=where_clause)

        #遍历图斑,分析LinkTBS对应的图斑的变化类型;分析存在LINKTBS的图斑和对应图斑的分组号
        for targetdata2 in targetdatas2:

            targettstybm2 = dealNone.dealNoneAndBlank(targetdata2['TSTYBM'])
            targetbhlx2 = dealNone.dealNoneAndBlank(targetdata2['bhlx'])

            targetNewBhlx2 = BhlxRules(targetbhlx2)
            targetValueDict[targettstybm2]['bhlx'] = targetNewBhlx2

            targetfzh2 = ""
            if targettstybm2 in targetValueDict:

                targetfzh2 = targetValueDict[targettstybm1]['fzh']

            if targetfzh1 == "" and targetfzh2 == "":

                newFzh = getNewFzh(fzhlist)
                targetfzh1 = newFzh
                targetfzh2 = newFzh

            elif targetfzh1 == "" and targetfzh2 != "":

                targetfzh1 = targetfzh2

            elif targetfzh1 != "" and targetfzh2 == "":

                targetfzh2 = targetfzh1

            elif targetfzh1 != "" and targetfzh2 != "" and targetfzh1 != targetfzh2:

                mergeFzhByFzh(targetfzh1, targetfzh2, fzhlist, mergeFzhList)

            targetValueDict[targettstybm1]['fzh'] = targetfzh1
            targetValueDict[targettstybm2]['fzh'] = targetfzh2

            arcpy.SetProgressorPosition()

        if len(targetdatas2) == 0:

            linktbsLack.append(targettstybm1)

    arcpy.AddMessage("5_共有%s个图斑存在LINKTBS但无法找到对应BSM图斑" % (len(linktbsLack)))

    return mergeFzhList
Esempio n. 10
0
def collectUnionAttributes(targetpath):

    targetValueDict = {}

    tbwymRelation = {}

    datas = []
    searchFields = [
        "unionfzh", "exp_bsm", "exp_tbybh", "exp_tbbh", "exp_zldwdm",
        "exp_dlbm", "exp_dlmc", "exp_gdlx", "exp_tbxhdm", "exp_tbxhmc",
        "exp_gdzzsxdm", "exp_gdzzsxmc", "exp_czcsxm", "exp_tblx", "exp_tbwym",
        "bhlx", "exp_wjzlx", "fzh"
    ]
    tempFields = [
        "unionfzh", "exp_bsm", "exp_tbybh", "exp_tbbh", "exp_zldwdm",
        "exp_dlbm", "exp_dlmc", "exp_gdlx", "exp_tbxhdm", "exp_tbxhmc",
        "exp_gdzzsxdm", "exp_gdzzsxmc", "exp_czcsxm", "exp_tblx", "exp_tbwym",
        "bhlx", "exp_wjzlx", "fzh"
    ]

    arcpyDeal.createTempDatas(searchFields,
                              tempFields,
                              targetpath,
                              datas,
                              sql_clause=(None, "ORDER BY unionfzh DESC"))

    lastdata = {}

    for data in datas:

        data["mergeTBWYM"] = []

        if lastdata == {}:

            targetValueDict[data["unionfzh"]] = data

            targetValueDict[data["unionfzh"]]["mergeTBWYM"].append(
                data["exp_tbwym"])

            lastdata = data

            continue

        if data["unionfzh"] != lastdata["unionfzh"]:

            targetValueDict[data["unionfzh"]] = data

        else:

            targetValueDict[data["unionfzh"]]["bhlx"] = "2"
            targetValueDict[data["unionfzh"]]["exp_tblx"] = "不一致图斑"

        targetValueDict[data["unionfzh"]]["mergeTBWYM"].append(
            data["exp_tbwym"])

        lastdata = data

        arcpy.SetProgressorPosition()

    for t in targetValueDict:

        mergeTBWYM = targetValueDict[t]

        for m in mergeTBWYM:

            tbwymRelation[m] = targetValueDict[t]["exp_tbwym"]

    return targetValueDict, tbwymRelation
Esempio n. 11
0
def collectUnionAttributes(targetpath):

    targetValueDict = {}

    tbwymRelation = {}

    datas = []
    searchFields = [
        "unionfzh", "LINKTBS", "BSM", "exp_tbybh", "exp_bsm", "exp_tbbh",
        "exp_zldwdm", "exp_dlbm", "exp_dlmc", "exp_gdlx", "exp_tbxhdm",
        "exp_tbxhmc", "exp_gdzzsxdm", "exp_gdzzsxmc", "exp_czcsxm", "exp_tblx",
        "exp_tbwym", "bhlx", "exp_wjzlx", "fzh"
    ]
    tempFields = [
        "unionfzh", "linktbs", "bsm", "exp_tbybh", "exp_bsm", "exp_tbbh",
        "exp_zldwdm", "exp_dlbm", "exp_dlmc", "exp_gdlx", "exp_tbxhdm",
        "exp_tbxhmc", "exp_gdzzsxdm", "exp_gdzzsxmc", "exp_czcsxm", "exp_tblx",
        "exp_tbwym", "bhlx", "exp_wjzlx", "fzh"
    ]

    arcpyDeal.createTempDatas(searchFields,
                              tempFields,
                              targetpath,
                              datas,
                              sql_clause=(None,
                                          "ORDER BY unionfzh,LINKTBS DESC"))

    lastdata = {"lastunionfzh": "", "datas": []}

    for data in datas:

        #分析存在LINKTBS的图斑的变化类型

        if lastdata["lastunionfzh"] == "":

            lastdata["lastunionfzh"] = data["unionfzh"]
            lastdata["datas"].append(data)

            continue

        #查找两个相邻图斑判断exp_bsm是否一致

        if data["unionfzh"] == lastdata["lastunionfzh"]:

            lastdata["datas"].append(data)

            continue

        else:

            targetValueDict[lastdata["lastunionfzh"]] = getFinal(lastdata)

            for ld in lastdata["datas"]:

                tbwymRelation[ld["exp_tbwym"]] = targetValueDict[
                    lastdata["lastunionfzh"]]["exp_tbwym"]

            lastdata = {"lastunionfzh": data["unionfzh"], "datas": [data]}

        arcpy.SetProgressorPosition()

    targetValueDict[lastdata["lastunionfzh"]] = getFinal(lastdata)

    return targetValueDict, tbwymRelation
Esempio n. 12
0
def collecteUnionFzh(targetpath, fzhlist, unionfzhlist, targetValueDict):
    """收集分组和变化类型"""

    mergeFzhList = {}

    datas = []
    sql_clause = (
        None,
        "ORDER BY exp_zldwdm,exp_dlbm,exp_dlmc,exp_gdlx,exp_tbxhdm,exp_tbxhmc,exp_gdzzsxdm,exp_gdzzsxmc,exp_czcsxm"
    )
    searchFields = [
        "bhlx", "exp_tbwym", "SHAPE@WKT", "fzh", "exp_zldwdm", "exp_dlbm",
        "exp_dlmc", "exp_gdlx", "exp_tbxhdm", "exp_tbxhmc", "exp_gdzzsxdm",
        "exp_gdzzsxmc", "exp_czcsxm"
    ]
    tempFields = [
        "bhlx", "exp_tbwym", "shpwkt", "fzh", "exp_zldwdm", "exp_dlbm",
        "exp_dlmc", "exp_gdlx", "exp_tbxhdm", "exp_tbxhmc", "exp_gdzzsxdm",
        "exp_gdzzsxmc", "exp_czcsxm"
    ]

    arcpyDeal.createTempDatas(searchFields,
                              tempFields,
                              targetpath,
                              datas,
                              sql_clause=sql_clause)

    lastdata = {}

    for data in datas:

        data["shpwkt"] = loads(data['shpwkt'])

        if lastdata == {}:

            lastdata = data

            targetValueDict[data["exp_tbwym"]][
                "unionfzhlist"] = getNewUnionFzh(unionfzhlist)
            targetValueDict[data["exp_tbwym"]]["fzh"] = data["fzh"]

            continue

        equals = True
        for field in tempFields:

            if field in ["shpwkt", "exp_tbwym", "fzh"]:

                continue

            if data[field] != lastdata[field]:

                equals = False

                break

        if data["bhlx"] == "1" or lastdata["bhlx"] == "1":

            targetValueDict[data["exp_tbwym"]][
                "unionfzhlist"] = getNewUnionFzh(unionfzhlist)

            targetValueDict[data["exp_tbwym"]]["fzh"] = data["fzh"]

            continue

        if equals == True and data['shpwkt'].intersects(lastdata['shpwkt']):

            targetValueDict[
                data["exp_tbwym"]]["unionfzhlist"] = targetValueDict[
                    lastdata["exp_tbwym"]]["unionfzhlist"]

            targetfzh = data["fzh"]
            lastfzh = lastdata["fzh"]

            mergeFzhByFzh(targetfzh, lastfzh, fzhlist, mergeFzhList)

        else:

            targetValueDict[data["exp_tbwym"]][
                "unionfzhlist"] = getNewUnionFzh(unionfzhlist)

        targetValueDict[data["exp_tbwym"]]["fzh"] = data["fzh"]

        lastdata = data

        arcpy.SetProgressorPosition()

    return mergeFzhList