I am starting up an enterprise GIS program at the Utility company I work for. We are a Generation and Transmission company. Our data was bad when I got here, it was in NAD27 in a .dwg and was off by at least 10 meters.
After a lot of hard work we got all the poles rectified and imported into a Geodatabase so they match aerial photography so everything lines up in ArcGIS Portal. Lines had already been created in the same coordinate system, but they too are considerably off. We can use the point to line geoprocessing tool, but there is a problem. We have a lot of what are called H-frame structures (they usually are higher voltage transmission lines) and each pole has an entry in our oracle database as they are considered separate structures. So we will have a pole 0222 and pole 0222A, about 15 feet apart depending on the construction. If they were a single pole structure I could the point to line tool and everything would be peachy. But because we have the two pole structures when we run the tool we end up with something that looks like this.
We, of course, don't want this zig zag type of line and want it to run between the two structures so it looks like this
What I'm trying to do then is write a script where it goes through the entire pole dataset (we have 30,000+ poles so drawing them in is out of the question) and selects a pole that is within 50ft (the span between each structure is much longer than that so it will select the other pole in the structure). I have it set to calculate the UTM coordinates of the structure adds the northings and eastings together and divides by 2 to find the point in the center between them. I suppose I could also tell it to draw a line in_memory and calculate the midpoint, but my approach seems more simple (maybe it isn't). Anyway, at this point I'm stuck using a for loop with the search cursor to select the line and just print out the easting and northing of the lines, then I will move on to the math part and the creating lines based on those midpoints. I had someone here who knows a lot more about python take a look at my code, but he wasn't familiar with the arcpy library so he said he couldn't help much.
This is the point that I'm stuck at.
I'm pretty rusty on my python and am not a programmer by trade.
#This Script will convert a series of poles to lines# #Power Co-op. Inc. Format" #Peter# #12 October 2017" #Import Modules import arcpy from arcpy import env import os import math import numpy #Set Workspace arcpy.env.workspace = "in_memory" #set Parameters# fc =r"P:\Scripts\pole_2_line\demo_data.gdb\demo_poles_short" fc_layer = arcpy.MakeFeatureLayer_management (fc, 'demo_poles') pole = "POLE_NUMBE" line = "LINE_NUMBE" coordinates = ['SHAPE@XY'] #select adjacent lines with arcpy.da.SearchCursor (fc_layer, coordinates) as cursor: for row in cursor: print row near_pole = arcpy.SelectLayerByLocation_management (fc_layer, 'WITHIN_A_DISTANCE',fc_layer,"50 feet", "NEW_SELECTION","NOT_INVERT") print near_pole