pyqgis

Plugin Builder 3.1

January 2, 2019

We’ve released version 3.1 of the Plugin Builder for QGIS 3.x. This version contains a number of bug fixes and performance enhancements. Here are some of the changes included since version 3.0.3: Fix issue with reload on generated plugins Move dialog creation to run method to improve startup performance Move help file generation files to proper method Include missing tags file Attempt to compile resources.qrc when plugin is generated (requires pyrcc5 in path) Set deployment directory in Makefile based on user OS (pb_tool is recommended over make) Check for valid URL format for tracker and repository Compiling Resource File If you have the resource compiler pyrcc5 in your path, the resource file will be compiled automatically when you generate your new plugin.

Where's my .qgis3 Folder?

March 12, 2018

There’s been several posts to GIS StackExchange along the lines of: Where’s my .qgis3 folder? Prior to QGIS 3, the .qgis/.qgis2 folder was found under your home directory. At version 3, the folder has moved to a more standard profile location for your operating system. There are a couple of ways to determine where the folder is located: Use the Settings->User Profiles->Open active profile folder menu item Use QgsApplication.qgisSettingsDirPath from Python or the console Here are the “standard” locations for Linux, Mac, and Windows, as found under your HOME directory:

Quick Guide to Getting Started with PyQGIS 3 on Windows

February 13, 2018

Getting started with Python and QGIS 3 can be a bit overwhelming. In this post we give you a quick start to get you up and running and maybe make your PyQGIS life a little easier. There are likely many ways to setup a working PyQGIS development environment—this one works pretty well. Contents Requirements Installing OSGeo4W Setting the Environment pb_tool Working on the Command Line IDE Example Workflow Creating a New Plugin Working with Existing Plugin Code Troubleshooting

Faking a Data Provider with Python

March 13, 2015

QGIS data providers are written in C++, however it is possible to simulate a data provider in Python using a memory layer and some code to interface with your data. Why would you want to do this? Typically you should use the QGIS data providers, but here are some reasons why you may want to give it a go: There is no QGIS data provider The generic access available through OGR doesn’t provide all the features you need You have no desire to write a provider in C++ No one will write a C++ provider for you, for any amount of money If you go this route you are essentially creating a bridge that connects QGIS and your data store, be it flat file, database, or some other binary format.

A Quick Guide to Getting Started with PyQGIS on Windows

October 9, 2014

Getting started with Python and QGIS can be a bit overwhelming. In this post we give you a quick start to get you up and running and maybe make your PyQGIS life a little easier. There are likely many ways to setup a working PyQGIS development environment—this one works pretty well. Contents Requirements Installing OSGeo4W Setting the Environment Python Packages Working on the Command Line IDE Example Workflow Creating a New Plugin Working with Existing Plugin Code Troubleshooting

QGIS Development with Plugin Builder and pb_tool

October 9, 2014

The Plugin Builder is a great tool for generating a working plugin project that you can customize. One of the main tasks in the development cycle is deploying the plugin to the QGIS plugin directory for testing. Plugin Builder comes with a Makefile that can be used on Linux and OS X to aid in development. Depending on your configuration, the Makefile may work on Windows. To help in managing development of your projects, we’ve come up with another option—a Python tool called pb_tool, which works anywhere QGIS runs.

Getting Paths with PyQGIS

November 6, 2013

When writing plugins or scripts it is often necessary to get information about the paths QGIS is using. For example, if we are writing a plugin that uses Python templates to create output based on user actions, we need to know the path to our installed plugin so we can find the templates. Fortunately the API provides an easy way to get at the information; here are a few examples:

New Version of the QGIS Script Runner Plugin

March 18, 2013

The Script Runner plugin allows you to manage and execute a collection of scripts in QGIS to automate tasks and perform custom processing. Version 0.6 of Script Runner has been released and includes these changes: Arguments can be passed to a script using keyword arguments Script output is logged to the Script Runner window Script output can be logged to disk Preferences dialog allows control of output and logging options Exceptions in scripts are displayed without interfering with console/logging output Context menu (right-click) to access script functions Edit script function uses system default editor or one you specify in preferences For a basic introduction to Script Runner see this post: Script Runner: A Plugin to Run Python Scripts in QGIS

PyQGIS Plugin Builder

February 21, 2009

One of the hurdles in developing a QGIS plugin with Python is just getting the basics down. Getting the plugin setup so it is recognized by QGIS and properly adds it’s menu and toolbar items can be a bit of a chore, especially the first time. To make the process easier, I put together a web tool to generate a plugin that can be used as a starting point. The tool creates a fully functional plugin that can be loaded in QGIS 1.

Custom Applications with QGIS

February 10, 2009

The recent release of QGIS 1.0 provides an excellent opportunity for developers looking to create standalone mapping applications with Python. I recently posted an article on creating a very simple standalone application with Python and QGIS 1.0. Much of the Python efforts thus far have been devoted to creating QGIS plugins. I think now that we have a stable API, you’ll begin to see more custom applications that meet a specialized need.