title: How to display output as vector layer in qgis?
body: <p>currently i am working on a project on spatial data mining, i have written a code for cluster analysis using db scan algorithm, all went well, i was getting  the output as 'FIGURE', but i was unable to get my output as vector layer,my aim here is to get output as vector layer so that i can visualize the output in qgis only. here is my code on db scan. please help</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>import numpy as np
  import matplotlib.pyplot as plt
  from sklearn.cluster import DBSCAN
  from sklearn import metrics
  #from sklearn.datasets.samples_generator import make_blobs
  
  from sklearn.preprocessing import StandardScaler
  
  
  def dbFun( _x,_original_vals):
      db = DBSCAN(eps=0.3, min_samples=20).fit(_x)
      core_samples_mask = np.zeros_like(db.labels_, dtype=bool)
      core_samples_mask[db.core_sample_indices_] = True
  
      labels = db.labels_
      #print(labels)
      n_clusters_ = len(set(labels)) - (1 if -1 else 0)
      print('Estimated number of clusters: %d' % n_clusters_)
      print("Wait plotting clusters.....")
      plotCluster(_x, labels, core_samples_mask, n_clusters_)
      return
  
  
  def plotCluster( _x, labels, core_samples_mask, n_clusters_):
     unique_labels = set(labels)
     colors = [plt.cm.Spectral(each)
            for each in np.linspace(0, 1, len(unique_labels))]
     for k, col in zip(unique_labels, colors):
        if k == -1:
          # Black used for noise.
           col = [0, 0, 0, 1]
  
        class_member_mask = (labels == k)
  
        xy = _x[class_member_mask &amp; core_samples_mask]
        plt.plot(xy[:, 0], xy[:, 1], 'o', markerfacecolor=tuple(col),
               markeredgecolor='k', markersize=14)
  
        xy = _x[class_member_mask &amp; ~core_samples_mask]
        plt.plot(xy[:, 0], xy[:, 1], 'o', markerfacecolor=tuple(col),
               markeredgecolor='k', markersize=6)
  
     plt.title('Estimated number of clusters: %d' % n_clusters_)
     plt.show()
     return
  
  _val = []
  
  
  l1=qgis.utils.iface.activeLayer()
  
  tempdat=[]
  
  import os
  
  for f1 in l1.getFeatures():
      geom=f1.geometry()
      
      g1=str(geom.asPoint())
      g11=g1.replace('(','')
      g111=g11.replace(')','')
    
      tempdat.append(g111)
  
  
  for abc in tempdat:
      aaa=abc.split(",")
      _val.append([aaa[0],aaa[1]])
  print aaa[1]
  print aaa[0]
  
  #print(_center)
  
  _val = np.asarray(_val)
  _val_original = _val
  _val_original =_val_original.astype('float32')
  _val = StandardScaler().fit_transform(_val_original)
  
  dbFun(_val, _val_original)
      #_len = len(_center)</code></pre>
  </div>
  </div>
  </p>