zoukankan      html  css  js  c++  java
  • arcpy 10.8计算最短路径,并复制出结果

    官方示例,记录而已
    #
    coding=utf-8 import arcpy from arcpy import env try: #Check out the Network Analyst extension license arcpy.CheckOutExtension("Network") #Set environment settings env.workspace = r'E:xxx est2Data80.gdb' env.overwriteOutput = True #Set local variables inNetworkDataset = r'RD/RD_ND' outNALayerName = "ClosestHospital" impedanceAttribute = "Length" accumulateAttributeName = ["Meters"] inFacilities = "DX/三甲医院2" inIncidents = "TMP/小区点" outLayerFile = "E:\xxx\test2\" + outNALayerName + "333.lyr" out_featureclass =r'E:xxx est2Data80.gdbTMPHOS' #Create a new closest facility analysis layer. Apart from finding the drive #time to the closest warehouse, we also want to find the total distance. So #we will accumulate the "Meters" impedance attribute. outNALayer = arcpy.na.MakeClosestFacilityLayer(inNetworkDataset,outNALayerName, impedanceAttribute,"TRAVEL_TO", "",1, "", "ALLOW_UTURNS") #Get the layer object from the result object. The closest facility layer can #now be referenced using the layer object. outNALayer = outNALayer.getOutput(0) #Get the names of all the sublayers within the closest facility layer. subLayerNames = arcpy.na.GetNAClassNames(outNALayer) #Stores the layer names that we will use later facilitiesLayerName = subLayerNames["Facilities"] incidentsLayerName = subLayerNames["Incidents"] #Load the warehouses as Facilities using the default field mappings and #search tolerance arcpy.na.AddLocations(outNALayer, facilitiesLayerName, inFacilities, "", "") #Load the Stores as Incidents. Map the Name property from the NOM field #using field mappings fieldMappings = arcpy.na.NAClassFieldMappings(outNALayer, incidentsLayerName) fieldMappings["Name"].mappedFieldName = "NOM" arcpy.na.AddLocations(outNALayer, incidentsLayerName, inIncidents, fieldMappings,"") #Solve the closest facility layer arcpy.na.Solve(outNALayer) #复制最短距离 routes 到其他地方 routes = arcpy.mapping.ListLayers(outNALayer, "Routes")[0] arcpy.CopyFeatures_management(routes, out_featureclass) #Save the solved closest facility layer as a layer file on disk with relative paths arcpy.management.SaveToLayerFile(outNALayer, outLayerFile,"RELATIVE") print "Script completed successfully" except Exception as e: # If an error occurred, print line number and error message import traceback, sys tb = sys.exc_info()[2] print "An error occurred on line %i" % tb.tb_lineno print str(e) print 'over'

  • 相关阅读:
    『计算机视觉』Mask-RCNN_推断网络其五:目标检测结果精炼
    『TensorFlow』高级高维切片gather_nd
    『计算机视觉』Mask-RCNN_推断网络其四:FPN和ROIAlign的耦合
    『计算机视觉』Mask-RCNN_推断网络其三:RPN锚框处理和Proposal生成
    『计算机视觉』Mask-RCNN_推断网络其二:基于ReNet101的FPN共享网络暨TensorFlow和Keras交互简介
    『计算机视觉』Mask-RCNN_推断网络其一:总览
    在ASP.NET MVC项目中使用React
    详解ABP框架的多租户
    .NET开发者如何愉快的进行微信公众号开发
    微软的R语言发行版本MRO及开发工具RTVS
  • 原文地址:https://www.cnblogs.com/yansc/p/14081575.html
Copyright © 2011-2022 走看看