OGR Clip function is getting slower and slower

المشرف العام

Administrator
طاقم الإدارة
I have a problem with OGR Clipping. I have shapefile with lines and I iterate the lines by one and make buffer around them. Then I clip all lines with buffer and then I compare their length. If the length is the same, I delete the line (mark with attribute). Problem is that I have many lines in shapefile and when the iteration begins, the loop is going pretty well, but around 500 loops is getting very slowly. Can somebody help with this?

Part of script with clipping loop:

while i < layer_lines_count: try: lines_feature = layer_lines.GetFeature(i) if lines_feature.GetField("delete") == 0: if datasource_clip.GetLayerCount() == 0: layer_clip = datasource_clip.CreateLayer("clip", geom_type = ogr.wkbLineString) geom_line = lines_feature.GetGeometryRef() buff = geom_line.Buffer(10) # Buff into layer feature_buff.SetGeometry(buff) layer_buffer.CreateFeature(feature_buff) # Clip fuction layer_lines.Clip(layer_buffer, layer_clip) #
 
أعلى