I wanted to know how qgis reads shapefile. Like i have choose any shapefile from qgis dialog then what are the steps that qgis take to read and render this shapefile data. Wrather it reads full shapefile data into memory or it opens file connection and reads and renders at runtime?

So far i have found this

layer = QgsVectorLayer(path, name, provider)
if not layer.isValid():
  raise IOError, "Failed to open the layer"

# add layer to the registry

# set extent to the extent of our layer

# set the map canvas layer set

I have opened documentation of each function but i am not successfull in understanding flow of how it is reading shapefile


Check the PyQGIS cookbook for code samples like this

layer = iface.addVectorLayer("/path/to/shapefile/file.shp", "layer name you like", "ogr")
if not layer:
  print "Layer failed to load!"
| improve this answer | |
  • i have seen it but i am more interested about this addvectorLayer function like i wanted to know how this is reading file weather it is storing full file in local memory or it is reading at runtime – user2174920 Dec 1 '15 at 10:12
  • and i also wanted to know how qgis is reading layer like how ot is reading each item in layer and then drawing it on map – user2174920 Dec 1 '15 at 10:14
  • i wanted to know this because when i load file of 400mb in qgis then qgis memory doesnot increase accordingly so i think qgis is not loading file in memory – user2174920 Dec 1 '15 at 12:17

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.