Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: function to write Qgis project #223

Open
aloboa opened this issue Oct 30, 2024 · 5 comments
Open

Feature request: function to write Qgis project #223

aloboa opened this issue Oct 30, 2024 · 5 comments
Labels
feature a feature request or enhancement

Comments

@aloboa
Copy link

aloboa commented Oct 30, 2024

I often do raster and vector processing using package terra and alike. At some point, I need to visualize results in Qgis. As soon as the results imply multiple raster and vector layers, a function to write an ad-hoc Qgis project would be great advantage.

@florisvdh florisvdh added the feature a feature request or enhancement label Nov 4, 2024
@ratnanil
Copy link

ratnanil commented Nov 7, 2024

This is exactly why I came here ☝🏼 (I literally just tooted this)

The ability to create a QGIS project XML from this package would be an awesome feature 💯

@florisvdh
Copy link
Member

florisvdh commented Nov 7, 2024

Thanks for sharing the enthusiasm 🙂. Several things are to be considered.

  • the focus of the package is on handling the qgis_process CLI utility, hence on geoprocessing algorithms that need input objects and generate output object(s), without the need for a QGIS project. This helps reproducibility at the R side of things. That will remain the core aim.
  • IMO it doesn't hurt to have a simple and restricted sidetool, e.g. qgis_launch(list(object_1, "filepath A", object_2)), that would call the qgis CLI utility (which is in the same directory as qgis_process), which accepts filepaths (it could perhaps be extended later with more arguments since that tool has more options). I understand this may come in handy for quick visual exploration in QGIS.
    • Not promising anything yet; it must remain manageable to implement it and it might be difficult to automatically test for various systems, so I would regard this as 'not guaranteed to work on every system'.
    • R objects could be handled by the internal as_qgis_argument() to derive file paths, as it does for qgis_run_algorithm().
    • Also it won't happen very soon if I'm to do it, but I'll keep it in mind. Of course contributions are also welcome.
  • I'm not inclined to generate full *.qgs project files with various options here, since this would take more effort from my side to get this robust. Also, it feels like 'very dedicated to the GUI' while the focus of this package is on the scripted approach, without a QGIS project. With qgis_launch() (above) the package would just defer further handling of files, CRS settings etc to QGIS; the user can then adjust things interactively in the GUI, and save as a project if needed. Directly creating or updating QGIS projects or interacting with them will better fit in another package.

@ratnanil
Copy link

ratnanil commented Nov 7, 2024

Thank you very much for your valuable thoughts on this! Quick question: I can't seem to find anything on the qgis CLI utility you mention, is this documented anywhere?

@florisvdh
Copy link
Member

I understand the confusion. I just mean the QGIS executable, which one can call from the command line, and from the command line it can take arguments (files in this case) and options. In a bash environment, its documentation is available with man qgis. I'm not sure whether this documentation is rendered somewhere on the web, but might be.

@aloboa
Copy link
Author

aloboa commented Nov 11, 2024

As far as I can see, the qgis command line options let the user open the layers, which I have been able to do such as:

qcomm <- paste("qgis", file.path(dirdata, "DI17_2_labels_R.tif"), "./DI17autoseg12/DI17_2_autoseg12.shp", "&")
system(qcomm)

but styling would need to be done through xml "QGIS layer definition files (.qlr)"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature a feature request or enhancement
Projects
None yet
Development

No branches or pull requests

3 participants