Yes. I've tried to create a OD matrix using the Python script from the other thread I posted using a shapefile with +3200 centroids. As I result I get a shapefile with +10 million lines with only one field called "ID" with value 0. What I want is that every line has incorporated some fields from the centroids shapefile.
A solution I thought was in doing a spatial join one to many of the empty created line shapefile with my centroids shapefile. I get as a result a shapefile with +20 million lines, in which every line has the data from a centroid. There is also a field created when I do the spatial join called FID_ID, in which two lines have the same FID_ID value (making it a OD pair). Then I can summarize data to create a table with a single FID_ID value, the ID of the origin point and the ID of the destination point.
While this gives a very close result to what I want, there is only one improtant problem: the order the lines ID have in the spatial join shapefile and the order the summarized table is created.
To put an example, I have this in the spatial join shapefile:
FID 14 Origin centroid: ID 3
FID 14 Destiny centroid: ID 5
FID 15: Origin centroid ID 4
FID 15: Destiny centroid ID 5
FID 16: Origin centroid ID 5
FID 16: Destiny centroid ID 6
FID 300 Origin centroid: ID 3
FID 300 Destiny centroid: ID 5
FID 301: Origin centroid ID 4
FID 301: Destiny centroid ID 5
FID 302: Origin centroid ID 5
FID 302: Destiny centroid ID 6
I want FID 14 being a OD flow 3-5, FID 15 being 4-5, and FID 16 being 6-5, and then FID 300 being 5-3, FID 301 being 5-4, and FID 302 being 5-6.
But due to the order in the table and in the data summarization I'm forced to have two flows 3-5, 4-5, and 5-6. I don't know how to be able to get that.
So I thought in trying to create directly the OD matrix from the script, since the script already assumes an origin centroid, and a destination centroid, while the spatial join just assumes two points in ID order.
I've slightly edited the code to this:
fc = 'celdas_centroids' # feature class
sr = arcpy.Describe(fc).spatialReference # spatial reference
lines = [] # output line list
geoms = [i[0] for i in arcpy.da.SearchCursor(fc,['SHAPE@','ID_GRUPO','SUM_POB_AS','NOMBRE_CEL'],spatial_reference=sr)] # point geometries
for geom1 in geoms: # loop through points
for geom2 in geoms: # compare to points
lines.append(arcpy.Polyline(arcpy.Array([[geom1.centroid,geom2.centroid]]),['SHAPE@','ID_GRUPO','SUM_POB_AS','NOMBRE_CEL'],sr)) # create line
arcpy.CopyFeatures_management(lines,r'F:\matriz_celdas_od.shp') # output to feature class
I got a line shapefile with just the ID field and the SHAPE field. I want to have too the ID_GRUPO (centroid ID) field of the origin centroid and the centroid field of the destination centroid (plus two more fields of information about the origin centroid and two fields of information about the destiny centroid, from the fields SUM_POB_AS, and NOMBRE_CEL).