Python 3.x arcpy python3中源-目标矩阵分析程序的输出问题

Python 3.x arcpy python3中源-目标矩阵分析程序的输出问题,python-3.x,arcpy,network-analysis,Python 3.x,Arcpy,Network Analysis,我已经使用arcpy(Python3和ArcGIS Pro)编写了一个关于OD矩阵分析(Network Analyst)的程序,但是我遇到了一些问题,代码没有将定义的数据作为原点,它只获得与目标和原点相同的数据,尽管我为两者定义了不同的数据。结果将在相同的起点和终点之间。它不能使用arcpy.GetParameterAsText正确地获取原始数据,但它可以从上一个进程(inDestinations)正确地获取目标数据。 第二个问题是:由于更改,我无法访问地理数据库中创建的数据集(ODCostMa

我已经使用arcpy(Python3和ArcGIS Pro)编写了一个关于OD矩阵分析(Network Analyst)的程序,但是我遇到了一些问题,代码没有将定义的数据作为原点,它只获得与目标和原点相同的数据,尽管我为两者定义了不同的数据。结果将在相同的起点和终点之间。它不能使用arcpy.GetParameterAsText正确地获取原始数据,但它可以从上一个进程(inDestinations)正确地获取目标数据。 第二个问题是:由于更改,我无法访问地理数据库中创建的数据集(ODCostMatrix1\ODLines1)的名称。因为我想在下一个进程中使用创建的数据集的输出,并且每当我运行程序时,它的名称都会自动更改(ODCostMatrix2\ODLines2)。如果我将OD矩阵的输出作为保存的图层文件导入到代码中,我如何从analyst network访问创建的行以进行下一个过程

任何帮助都会被拒绝,提前谢谢

#  generate Tesselation
import arcpy
#Check out the Network Analyst extension license
arcpy.CheckOutExtension("Network")
# set workspace 
gdb = arcpy.GetParameterAsText(0)
# set basic setting
arcpy.env.workspace = gdb
arcpy.env.overwriteOutput  = True
output_tesselation = arcpy.GetParameterAsText(2)
output_feature = gdb + "\\" + output_tesselation
extent = arcpy.GetParameterAsText(3)
shpae_type = arcpy.GetParameterAsText(4)
area = arcpy.GetParameterAsText(5)

arcpy.GenerateTessellation_management(output_feature, extent, shpae_type, area)
arcpy.AddMessage("Tesselation was generated successfully.")


# 2. calculate centroid of each tesselation--------------------------------------

# calculate centroid of x and y for polygons of tessalation
arcpy.AddField_management(output_feature, "Longitude", "DOUBLE")
arcpy.AddField_management(output_feature, "Latitude", "DOUBLE")
arcpy.CalculateField_management(output_feature, "Longitude", "!SHAPE.CENTROID.X!", "PYTHON3")
arcpy.CalculateField_management(output_feature, "Latitude", "!SHAPE.CENTROID.Y!", "PYTHON3")

# convert table to table process: table of tesselation to new table
new_table = arcpy.TableToTable_conversion(output_feature, gdb , "new_table")

# convert created table to x and y points
centroid_tesselation_point = arcpy.management.XYTableToPoint(new_table, gdb + "\\" + "centroid_tesselation_point", "Longitude", "Latitude", "", arcpy.SpatialReference(3857))
arcpy.AddMessage("The centroid points of tesselation was created.")


# 3. calculate reach time of each employee to each centroid of tesselations------

#Set local variables
inNetworkDataset = "S:\\GIS\\Stammdaten\\Network_Dataset_20190924.gdb\\ND\\ND_20190924"
outNALayerName = "WorkerTONewOfficeDrivetimeMatrix"
impedanceAttribute = "Time_Car"        # Time_Car , Time_Walk , Length

inOrgins = arcpy.GetParameterAsText(1)
inDestinations = gdb + "\\" + "centroid_tesselation_point"
outLayerFile = "C:\\Users\\somaye.fazeli\\ArcGisProject_Test\\" + outNALayerName

#Create a new OD Cost matrix layer
outNALayer = arcpy.na.MakeODCostMatrixLayer(inNetworkDataset, outNALayerName, impedanceAttribute)

#Get the layer object from the result object. The OD cost matrix layer can 
#now be referenced using the layer object.
outNALayer = outNALayer.getOutput(0)

#Get the names of all the sublayers within the OD cost matrix layer.
subLayerNames = arcpy.na.GetNAClassNames(outNALayer)

#Stores the layer names that we will use later
originsLayerName = subLayerNames["Origins"]
destinationsLayerName = subLayerNames["Destinations"]

#Load the warehouse locations as origins using a default field mappings and
#a search tolerance of 1000 Meters.
arcpy.na.AddLocations(outNALayer, originsLayerName, inOrgins)
arcpy.AddMessage("Origin data was imported.")


arcpy.na.AddLocations(outNALayer, destinationsLayerName, inDestinations)
arcpy.AddMessage("Destination data was imported.")

#Solve the OD cost matrix layer
arcpy.na.Solve(outNALayer)

#Save the solved OD cost matrix layer as a layer file on disk with relative path
arcpy.SaveToLayerFile_management(outNALayer, outLayerFile, "ABSOLUTE")

arcpy.AddMessage("Newtork Analysis completed successfully")

# calculate average time of each destinaiton
input_layer = gdb + "\\ODCostMatrix1\\ODLines1"
arcpy.Statistics_analysis(input_layer, gdb + "\\" + "Mean_Drive_Time", [["Total_Time_Car", "MEAN"]], "DestinationID")

对不起,我在代码中写错了。目标变量的正确值为:inDestinations=centroid\u tesselation\u point您可能希望将其发布到gis.stackexchange.com中。