简体   繁体   English

编写python脚本以自动化QGIS(Qt)任务

[英]writing python script to automate QGIS (Qt) tasks

I am using QGIS to do some repetitive mapping work. 我正在使用QGIS进行一些重复的映射工作。 I have a floor plan of an elderly home which is digitized into QGIS with the bed numbers properly labeled, and a spreadsheet with the bed numbers and all the other attributes that belong to that bed. 我有一个养老院的平面图,它已被数字化到QGIS中,并正确标记了床号,还有一个电子表格,其中包含床号和属于该床的所有其他属性。

I need to create multiple layers and visualize them one by one, currently I am using the 'save as image' function. 我需要创建多个图层并逐一可视化它们,目前我正在使用“另存为图像”功能。 It's OK if I only need to work on it once however I have >30 elderly homes, and 4-5 layers for each home to visualize. 如果只需要处理一次就可以了,但是我有30多个老年房屋,每个房屋都有4-5层可视化。 QGIS is already a lot better than ArcGIS, but I still feel a bit overwhelmed when I realize that I need to do them all manually. QGIS已经比ArcGIS好很多,但是当我意识到需要手动完成所有操作时,我仍然感到有些不知所措。

I am looking to Python for automation, but seems it is mainly used in QGIS for creating plugins. 我正在寻找Python来实现自动化,但似乎它主要在QGIS中用于创建插件。

Being an R user I am used to automating all repetitive tasks. 作为R用户,我习惯于自动执行所有重复性任务。

I know that QGIS is written using Qt4, Does anyone have knowledge of a QT4 script that I can use as a model to automate QGIS? 我知道QGIS是使用Qt4编写的,有人知道我可以用作自动QGIS的模型的QT4脚本吗?

Can anyone tell me whether it is possible, and if yes, how? 谁能告诉我是否可行,如果可以,怎么办?

Thanks. 谢谢。

If you just want to execute a script, have a look at the Python Console (Plugins->Python Console). 如果只想执行脚本,请查看Python控制台(插件-> Python控制台)。

Also consider writing a QGIS Python plugin. 还可以考虑编写QGIS Python插件。 It's really easy. 真的很简单。

Besides these two options, you can also use qgis as a Python library completely outside of QGIS (eg as a commandline script) - but I don't know if that's what you're looking for. 除了这两个选项,您还可以将qgis完全用作QGIS之外的Python库(例如,作为命令行脚本)-但我不知道您是否在寻找它。 The excellent PyQIS cookbook calls this "Python Applications" 出色的PyQIS食谱将其称为“ Python应用程序”

http://www.qgis.org/pyqgis-cookbook/intro.html http://www.qgis.org/pyqgis-cookbook/intro.html

It's all open source, so if you look to the extensive QGIS Python plugin repositories, you can simply look for a plugin that does similar things like you have in mind and use that code as a template. 所有这些都是开源的,因此,如果您查看大量的QGIS Python插件存储库,则可以简单地寻找一个可以实现类似想法的插件,并将该代码用作模板。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM