I have an excel file with x and y. how can I use this excel file in qgis' python console as point vector layer to make polygon with all the points in the file.(it is important for me to use python)

  • Can you clarify more, you want to create one polygon from all points in the excel file ? and do you want it specially with python or you are okay to use QGIS features to import the file ?
    – Shiko
    Sep 26, 2016 at 15:10
  • I edited the question
    – Mahdi.M
    Sep 26, 2016 at 16:19
  • 1
    Perhaps this post might help: How to draw polygons from the python console?
    – Joseph
    Sep 27, 2016 at 13:57
  • I saw this document before, but my problem is how to read the points from an external file, and not adding the points manually.?
    – Mahdi.M
    Sep 27, 2016 at 14:33
  • Can you edit your question and include a sample screen shot of what your excel/data looks like so we can see the structure?
    – artwork21
    Sep 27, 2016 at 17:09

1 Answer 1


PyQGIS supports delimited files including CSV. For example in the QGIS Python Console you could do the following:

uri = "file:///C:/data/points.csv?type=csv&xField=x&yField=y&spatialIndex=no&subsetIndex=no&watchFile=no"

vlayer = QgsVectorLayer(uri, 'My Points', "delimitedtext")

Just replace the xField and yField variables with the x,y column names in your CSV.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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