I have shapefile with lines that shows surface water runoff. I need to clear and simplify these lines by condition that if some lines are near by other and has similar running, this lines has to be deleted. I'm using Python 2.7, ArcMAp 10.2 and Windows 7. I have tried some solutions like:
Solution 1: Iterate through lines using ESRI arcpy module, make buffer with 10 meters distance on each line separately and then use Select By Location with Completely Contains condition (without the original line from which it was buffer made) and delete this lines. Then iterate next line. This works fine, but Select By Location was TOO slow, and because I have 244 shapefiles that needs to be cleaned and together contains 48 milions of lines, so it approx. 200 000 line per shapefile and I need script to do it quicky.
Solution 2: Like in previous solution, I use iteration through lines and separately use buffer, but then I want to avoid to use Select By Location, so I use Clip the lines with buffer and then compare the lengths of unclipped lines and clipped lines. If the lengths was the same - so it means that lines completely belong into buffer - I sum the IDs of this lines to list and delete from original shapefile (no from the clipped, it was only temp). But in this solution, there was Clip function so damn slow, so it is not usable for me.
Now I want to leave using arcpy module, because it not suitable for using in such a large data. I want to use GDAL/OGR to reconsturct a procedure of one of previous solution, but I'm really loosing in OGR algorithms. All that I founf out till now is load shapefile and iterate through lines, but I can't figureed out how to make buffer, identify nearby lines with similar running and delete them. I would appreciate any tip and help. Maybe there is better and simple solution different from mine, but I can!t see it. Thanks!
Pictures showing iteration on one line:
And pictures showing final result:
أكثر...
Solution 1: Iterate through lines using ESRI arcpy module, make buffer with 10 meters distance on each line separately and then use Select By Location with Completely Contains condition (without the original line from which it was buffer made) and delete this lines. Then iterate next line. This works fine, but Select By Location was TOO slow, and because I have 244 shapefiles that needs to be cleaned and together contains 48 milions of lines, so it approx. 200 000 line per shapefile and I need script to do it quicky.
Solution 2: Like in previous solution, I use iteration through lines and separately use buffer, but then I want to avoid to use Select By Location, so I use Clip the lines with buffer and then compare the lengths of unclipped lines and clipped lines. If the lengths was the same - so it means that lines completely belong into buffer - I sum the IDs of this lines to list and delete from original shapefile (no from the clipped, it was only temp). But in this solution, there was Clip function so damn slow, so it is not usable for me.
Now I want to leave using arcpy module, because it not suitable for using in such a large data. I want to use GDAL/OGR to reconsturct a procedure of one of previous solution, but I'm really loosing in OGR algorithms. All that I founf out till now is load shapefile and iterate through lines, but I can't figureed out how to make buffer, identify nearby lines with similar running and delete them. I would appreciate any tip and help. Maybe there is better and simple solution different from mine, but I can!t see it. Thanks!
Pictures showing iteration on one line:


And pictures showing final result:


أكثر...