1

I have fetch data from database and draw it on qgis 2.8 as vector layer it works fine with limited data but for large data it will not work and goes into not responding stage, I am unable to understand the problem. My code is follows

 layer =  QgsVectorLayer("Point?field=gid:integer&field=lattitude:double&
 field=longitude:double&field=depth:integer   
 &crs=EPSG:4326","items","memory")

 QgsMapLayerRegistry.instance().addMapLayer(layer)

 for i in range(len(Receivers)):
      # add a feature
      feature = QgsFeature()
      X = Receivers[i][1]
      Y = Receivers[i][2]
      temp=[] 
      #X= X cordinate  longitude
      #Y= Y cordinate  latitude

     feature.setGeometry(QgsGeometry.fromPoint(QgsPoint(Y,X))) 

     length=len(Receivers[i])
     for j in range(0,length):                                    
           temp.append(Receivers[i][j])
     feature.setAttributes(temp)                                   
     layer.startEditing()
     layer.addFeature(feature, True)

     layer.commitChanges()                         
     layer.updateExtents()

Receiver list contain the data fetch from database (postgres)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.