4

I'm working on a dataset that is readily available as a pandas dataframe object. Now, I would like to import this data as a layer in QGIS. I didn't find any helpful library or code to do so. So, I resorted to converting the dataframe to a csv file and then importing this as a layer using PyQGIS api.

Is there any way I can import the dataframe directly, without having to write it to a shapefile or a csv file?

4
  • Do you have geometries in the dataframe or is it only a table?
    – Bera
    Commented Jul 5, 2018 at 5:16
  • It is only a table. Commented Jul 5, 2018 at 5:22
  • Can you show us what your dataframe looks like? You can probably use memory layer. Just convert each line of your dataframe to feature.
    – YoLecomte
    Commented Jan 6, 2019 at 15:54
  • If you use pandas inside QGIS you can write to a QGSVectorLayer stored in memory
    – Bera
    Commented Sep 8, 2019 at 8:17

1 Answer 1

2

Dataframe is in-memory object that lives inside your Jupyter Notebook (or other development tool) and QGIS reads from file. There is no simple way to move objects between different processes.

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.