def replace_lines_to_point(line_lyrs, old_point, new_point): x = old_point[0].coords[0][0] y = old_point[0].coords[0][1] buff = Polygon([(x-1, y-1), (x-1, y+1), (x+1, y+1), (x+1, y-1), (x-1, y-1)]) buff.srid = old_point.srid for line_lyr in line_lyrs: # get intersection lines query = line_lyr.feature_query() #query.intersects(buff) query.geom() # replace point in lines for f in query(): line = f.geom[0] new_line_points = [] need_reconstruct = False for vertex in line.coords: if vertex == old_point[0].coords[0]: new_line_points.append(new_point[0].coords[0]) need_reconstruct = True else: new_line_points.append(vertex) if need_reconstruct: new_geom = MultiLineString([new_line_points,]) f.geom = new_geom line_lyr.feature_put(f)