zoukankan      html  css  js  c++  java
  • arcgis使用python,做arctoolbox,渔网裁剪gdb里的要素,四等分

    arcgis使用python,做arctoolbox,渔网裁剪gdb里的要素,四等分:

    # ecoding=gbk
    coding = 'utf-8'
    import os
    import shutil
    import arcpy
    import arcpy.cartography as CA
    import arcpy.management as DM
    import arcpy.analysis as AN
    
    inSacle=1
    def setupProcess():
        inputGDB1 = arcpy.GetParameterAsText(0);
        inputGDB2 = arcpy.GetParameterAsText(1);
        
        #inputGDB1 = "E:\001.yangdebin\渔网裁剪\LCA\DLGGC\JC20_340401.gdb"
        #inputGDB2 = "E:\001.yangdebin\渔网裁剪\LCA\BGData\JC19_340401.gdb"
        
        lca1= inputGDB1 + "/LcrDataset/UV_LCRA";
        lca2= inputGDB2 + "/LcrDataset/V_LCRA";
        desc = arcpy.Describe(lca1);
        extent = desc.extent;
        sr = desc.spatialReference;
    
        #创建渔网
        fishnet = inputGDB1 + "/LcrDataset/fishnet";
        originCoordinate = str(extent.XMin) + " " + str(extent.YMin);
        yAxisCoordinate = str(extent.XMin) + " " + str(int(extent.YMin)+10);
        oppositeCoorner = str(extent.XMax) + " " + str(extent.YMax);
        arcpy.CreateFishnet_management(fishnet, originCoordinate, yAxisCoordinate, 0, 0, 2, 2, oppositeCoorner, "NO_LABELS", lca1, "POLYGON");
        print("--------创建渔网Success!--------")
    
        #添加标记字段
        arcpy.AddField_management(fishnet, "Index", "TEXT","", "", 4);
        arcpy.CalculateField_management(fishnet, "Index", "[OID]","VB")
        
        #标记
        idenFeatures1 = inputGDB1 + "/LcrDataset/idenFeatures";
        idenFeatures2 = inputGDB2 + "/LcrDataset/idenFeatures";
        arcpy.Identity_analysis(lca1, fishnet, idenFeatures1);
        arcpy.Identity_analysis(lca2, fishnet, idenFeatures2);
        
        outPath = arcpy.GetParameterAsText(2);
        #outPath = "E:\001.yangdebin\渔网裁剪\LCA\result"
        
        (filepath1,gdbname1) = os.path.split(inputGDB1);
        (filepath2,gdbname2) = os.path.split(inputGDB2);
    
        #分别输出
        arcpy.CreateFolder_management(outPath, "block_1");
        arcpy.CreateFolder_management(outPath+"/block_1/", "DLGGC");
        arcpy.CreateFileGDB_management(outPath+"/block_1/DLGGC", gdbname1);
        arcpy.CreateFeatureDataset_management(outPath+"/block_1/DLGGC/"+gdbname1, "LcrDataset", sr);
        arcpy.FeatureClassToFeatureClass_conversion(idenFeatures1, outPath+"/block_1/DLGGC/"+gdbname1+"/LcrDataset", "UV_LCRA", "Index = '1'");
        arcpy.CreateFolder_management(outPath+"/block_1/", "BGData");
        arcpy.CreateFileGDB_management(outPath+"/block_1/BGData", gdbname2)
        arcpy.CreateFeatureDataset_management(outPath+"/block_1/BGData/"+gdbname2, "LcrDataset", sr);
        arcpy.FeatureClassToFeatureClass_conversion(idenFeatures2, outPath+"/block_1/BGData/"+gdbname2+"/LcrDataset", "V_LCRA", "Index = '1'");
        print("--------创建block_1 ---Success!--------")
        
        arcpy.CreateFolder_management(outPath, "block_2");
        arcpy.CreateFolder_management(outPath+"/block_2/", "DLGGC");
        arcpy.CreateFileGDB_management(outPath+"/block_2/DLGGC", gdbname1)
        arcpy.CreateFeatureDataset_management(outPath+"/block_2/DLGGC/"+gdbname1, "LcrDataset", sr);
        arcpy.FeatureClassToFeatureClass_conversion(idenFeatures1, outPath+"/block_2/DLGGC/"+gdbname1+"/LcrDataset", "UV_LCRA", "Index = '2'");
        arcpy.CreateFolder_management(outPath+"/block_2/", "BGData");
        arcpy.CreateFileGDB_management(outPath+"/block_2/BGData", gdbname2)
        arcpy.CreateFeatureDataset_management(outPath+"/block_2/BGData/"+gdbname2, "LcrDataset", sr);
        arcpy.FeatureClassToFeatureClass_conversion(idenFeatures2, outPath+"/block_2/BGData/"+gdbname2+"/LcrDataset", "V_LCRA", "Index = '2'");
        print("--------创建block_2 ---Success!--------")
        
        arcpy.CreateFolder_management(outPath, "block_3");
        arcpy.CreateFolder_management(outPath+"/block_3/", "DLGGC");
        arcpy.CreateFileGDB_management(outPath+"/block_3/DLGGC", gdbname1)
        arcpy.CreateFeatureDataset_management(outPath+"/block_3/DLGGC/"+gdbname1, "LcrDataset", sr);
        arcpy.FeatureClassToFeatureClass_conversion(idenFeatures1, outPath+"/block_3/DLGGC/"+gdbname1+"/LcrDataset", "UV_LCRA", "Index = '3'");
        arcpy.CreateFolder_management(outPath+"/block_3/", "BGData");
        arcpy.CreateFileGDB_management(outPath+"/block_3/BGData", gdbname2)
        arcpy.CreateFeatureDataset_management(outPath+"/block_3/BGData/"+gdbname2, "LcrDataset", sr);
        arcpy.FeatureClassToFeatureClass_conversion(idenFeatures2, outPath+"/block_3/BGData/"+gdbname2+"/LcrDataset", "V_LCRA", "Index = '3'");
        print("--------创建block_3 ---Success!--------")
        
        arcpy.CreateFolder_management(outPath, "block_4");
        arcpy.CreateFolder_management(outPath+"/block_4/", "DLGGC");
        arcpy.CreateFileGDB_management(outPath+"/block_4/DLGGC", gdbname1)
        arcpy.CreateFeatureDataset_management(outPath+"/block_4/DLGGC/"+gdbname1, "LcrDataset", sr);
        arcpy.FeatureClassToFeatureClass_conversion(idenFeatures1, outPath+"/block_4/DLGGC/"+gdbname1+"/LcrDataset", "UV_LCRA", "Index = '4'");
        arcpy.CreateFolder_management(outPath+"/block_4/", "BGData");
        arcpy.CreateFileGDB_management(outPath+"/block_4/BGData", gdbname2)
        arcpy.CreateFeatureDataset_management(outPath+"/block_4/BGData/"+gdbname2, "LcrDataset", sr);
        arcpy.FeatureClassToFeatureClass_conversion(idenFeatures2, outPath+"/block_4/BGData/"+gdbname2+"/LcrDataset", "V_LCRA", "Index = '4'");
        print("--------创建block_4 ---Success!--------")
        
        arcpy.Delete_management(idenFeatures1, "");
        arcpy.Delete_management(idenFeatures2, "");
        arcpy.Delete_management(fishnet, "");
        print("--------全部---Success!--------")
        
    
    if __name__ == "__main__":
        setupProcess()
    版权所有,违者必究
  • 相关阅读:
    git如何进行远程分支切换
    js中实现多态
    css选择器中:first-child与:first-of-type的区别
    js实现图片延时加载的原理
    认识AMD、CMD、UMD、CommonJS
    CORS详解
    JS实现继承的五种方式
    jQuery.fn.extend() 函数详解
    Java基础面试题
    Java面试题集
  • 原文地址:https://www.cnblogs.com/ydbgis/p/14199890.html
Copyright © 2011-2022 走看看