For my own data analysis pipeline, I am running a split screen setup with IPython notebooks on one side, generating variables from source data, pushing them to a CSV file which QGIS then reads/joins to an appropriate geography, instantly visible on the other side of the screen.
I would like to push the control of the running instance of QGIS to the ipython notebook, in effect allowing a super quick calculation/visualization cycle.
Right now I can do this in the QGIS python console with something like this:
canvas = qgis.utils.iface.mapCanvas()
cLayer = canvas.currentLayer()
canvas.refresh()
but I would like to:
- connect to an existing instance of qgis from an external Python environment
- at a minimum refresh the map, after each re-write to the csv from ipython notebook, but preferably
- re-calculate breaks (using quantiles, natural breaks) based on the newly joined values
How can I achieve this?
F5
. On the other side in the IPython notebook, write a function that saves your data to the CSV and make sure that function will always get imported into your global namespace, by using thePYTHONSTARTUP
environment variable for example.F5
in QGIS, and save to a simple function in notebook. Still two actions, but should nevertheless speed up your cycle. A one button solution would be possible I guess, but considerably more complex, and you'd need to be willing to invest quite some time into it.