QGIS Planet

Faking a Data Provider with Python

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.

The Long Road to Gutsy

I guess Ubuntu must be popular. I’m just trying to upgrade my Feisty install so I can do the upgrade to Gutsy. Looks like it’s going to take a while…

Where's my .qgis3 Folder?

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:

Plugin Builder 2.8.1

This minor update to the Plugin Builder allows you to choose where your plugin menu will be located. Previously your menu was placed under the Plugins menu. At version 2.8.1 you can choose from the following main menu locations: Plugins Database Raster Vector Web Plugins is the default choice when you open Plugin Builder. The value you choose is also written to the category field in your metadata.txt file.

QGIS Workshop at FOSS4G2007 - A Done Deal

Well, the QGIS workshop at FOSS4G2007 is history. We had a capacity crowd and covered a lot of ground in a short 3 hours. Rumor is there are some pictures and heaven forbid, audio from the workshop floating around. Maybe they’ll surface at some point this week. I have a few LiveCDs left over and some of the coveted QGIS carabiners. If you run into me at the conference and want either, just ask.

Google Summer of Code 2010 - Quantum GIS

The application deadline for the Google Summer of Code is nearing (April 9). If you are interested in working on QGIS as part of GSOC and need ideas, please see Quantum GIS Wiki. We are waiting for your proposal!

Vim and CMake Out-of-Source Builds

If you use Vim you probably know you can use the make command to build your project. The make command looks for a Makefile in your current directory. If you are editing a file that is not in the current directory (meaning you use some Vim magic to change to the directory containing your edit buffer), make will start below the top-level of your build directory. This is often the case when doing an out-of-source build with CMake.

Spatial Galaxy

This site aims to bring out some of the latest and sometimes not-so-greatest happenings in the GIS world. We’ll focus to large extent on Open Source software but hopefully mix it up to keep things interesting. We’ll explore things from the new and exciting to the dull and mundane. There are a lot of GIS/Spatial sites out there. Hopefully we can provide some content of interest and you will add this one to those you visit frequently.

QGIS Training Opportunities

We’re planning a couple of training classes for March: Introduction to QGIS Extending QGIS with Python Each is a one day class and we plan to run them back to back. If you are local or just want to come to Alaska in March for some spring skiing, northern lights viewing, or to experience the equinox, please hop over to GeoApt and let us know so we can plan accordingly.

Getting Paths with PyQGIS

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:

Plugin Builder 2.8

Plugin Builder 2.8 is now available. This is a minor update that adds: Suggestion for setting up an issue tracker and creating a code repository Suggestion for a home page Tag selection from a list of current tags Documentation update, including information about using pb_tool to compile, deploy, and package your plugin New URLs for Plugin Builder’s home page and bug tracking Optional is now Recommended In previous versions the following items were “Optional” when creating a new plugin:

PyQGIS Resources

Here is a short list of resources available when writing Python code in QGIS. If you know of others, please leave a comment. Blogs/Websites In alphabetical order: GIS StackExchange Kartoza Linfiniti Lutra Consulting Nathan Woodrow Nyall Dawson Twitter #pyqgis Documentation Choose the version to match your QGIS install PyQGIS Cookbook QGIS API Example Code Existing plugins can be a great learning tool Code Snippets in the PyQGIS Cookbook Plugins/Tools Script Runner: Run scripts to automate QGIS tasks Plugin Builder: Create a starter plugin that you can customize to complete your own plugin Plugin Reloader: Allows you to reload a plugin from within QGIS pb_tool: Tool to compile and deploy your plugins Books PyQGIS Programmers Guide Geospatial Desktop: GIS Scripting (PDF)

A Quick Guide to Getting Started with PyQGIS on Windows

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

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.

Why QGIS Class Names Start with Qgs

If you’re a developer, or have looked at the QGIS source code, you’ve likely noticed that most C++ classes in the project start with Qgs. Back before the dark ages of QGIS, Trolltech (now Digia) allowed you to reserve name prefixes for classes that used the Qt framework. Shortly afterwards, I reserved the gs prefix for my use, resulting in class names that start with Qgs. You might think this is based on some mangling of words like QGIS or perhaps GIS, but it was purely egocentric:

The PyQGIS Programmer's Guide

The PyQGIS Programmer’s Guide is now available in both paperback and PDF. A sample chapter is also available for download. The book is fully compatible with the QGIS 2.x series of releases. See locatepress.com for details.

PyQGIS Programmer's Guide Available

The preview release of the PyQGIS Programmer’s Guide is now available for purchase from Locate Press.

QGIS Plugin of the Week: qNote

This week we look at a newly arrived plugin named qNote. This plugin allows you to create a note and store it in a QGIS project file. When the project is loaded, the note is restored and can be viewed in the qNote panel. This little plugin provides a way to attach metadata to a project. Things you might want to include in a note are: Content of the project Purpose Area of interest Where the data came from Who created the project This information can be helpful when sharing a project or when you forget what you did six months after the fact.

New Version of the QGIS Script Runner Plugin

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

Littering Your Python Path: The Road to Destruction

Well not quite destruction, but a bit of hair pulling… While working on an update to the Plugin Builder, I encountered a small problem. The Plugin Builder displays the version number in the title bar of its main window. After bumping the version number to 1.8.4 in all the requisite places, it still showed 1.8.3 when testing. Using grep on all the source files revealed no instance of 1.8.3 in any file.

Back to Top

Sustaining Members