Page 2 of 57 (1138 posts)

  • talks about »

Tags

Last update:
Fri Jul 25 15:35:09 2014

A Django site.

QGIS Planet

Colour shortcuts in QGIS 2.4

Quick poll… what’s the most frustrating thing about GIS? Fighting with colour plotters? Trying to remember GDAL command line syntax? MapInfo’s new ribbon interface* [1]? All of the above?

Wrong!

It’s getting a colour from here:

colour1

…all the way over to here:

colour2

Since the dawn of GIS humanity has struggled with this simple task* [2]. We’ve come up with multiple techniques for solving this problem, ranging from the RSI inducing “select and copy red value, alt-tab, paste, alt-tab, select and copy green value, alt-tab, paste, etc….” method, through to chanting “70, 145, 160… 70, 145, 160… 70, 145, 150… 70, 145, 150” to ourselves as we frantically try and rearrange dialogs to find the destination colour picker, all the while avoiding strange looks from co-workers.

Fortunately, QGIS 2.4 is coming to the rescue! Now, you can right click on any of QGIS’ colour picker buttons for a handy copy/paste colour shortcut menu. Pasting colours works from a whole range of formats, including hex codes, color names, and css-style “rgb” and “rgba” strings.

Fixed!

Problem solved!

Even better, you can just drag colours from one colour button to another:

Fixed again...

… and solved again…

Or, drag a colour from GIMP and drop it onto a QGIS colour button:

x

… and yet again!

Or even drag a colour from a QGIS button directly onto a shape in Inkscape! All this win is coming your way in QGIS 2.4, due June 2014.

[1] Pre-empting the inevitable flood of complaints when this new interface is rolled out
[2] I assume

And now… colour preview modes in QGIS’ map canvas

As a quick follow-up to my last post on colour preview modes for the print composer in QGIS 2.4, this feature has also been added to the main map canvas window! Now it’s even easier to adjust your symbol colours and immediately see how they’d appear under a range of different circumstances:

Colour previews modes for the map canvas

Colour previews modes for the map canvas

 

Packaging PostGIS dev releases with Docker

Packaging PostGIS dev releases with Docker

We recently added support for GML curves to PostGIS, which enables TinyOWS to deliver WFS requests with curve geometries. More on this in a later post. This enhancement is in the current PostGIS developement version (SVN master) and not released yet. To enable our customer testing this functionality, we had to build packages for their server environment which is Ubuntu Precise with UbuntuGIS repositories. After working with Linux LXC containers and it's predecessor VServer for years, Docker was a logical choice for a clean reproducible build environment.

Rebuilding a Debian package is usually quite easy:

apt-get build-dep <package>
cd <packagedir>
#Make your changes
dch -i
dpkg-buildpackage

But getting build dependencies for PostGIS currently fails with libssl-dev conflicts, maybe because the dev packages got out of sync after the recent Heartblead updates. So the Dockerfile uses equivs to build a dummy package which satisfies the dependencies.

The command

docker run -v /tmp:/pkg sourcepole/postgis-svn-build-env sh -c 'cp /root/*postgis*.deb /pkg'

loads the Docker image with packages built from the latest SVN version of PostGIS in /root and copies the deb files from the containter into /tmp.

Now we're ready to install these packages on the Ubuntu server:

sudo dpkg -i /tmp/*postgis*.deb

Thats it. Feedback welcome!

@PirminKalberer

P.S.

If you happen to be a developer, then you may prefer running a cutting-edge version of PostGIS in a Docker container instead of building packages. Our colleagues from Oslandia just published how to do this.

Installing PostGIS on Fedora 20

In order to explore all the new interfaces to PostGIS (from QGIS, GDAL, GRASS GIS 7 and others) I decided to install PostGIS 2.1 on my Fedora 20 Linux box. Eventually it is an easy job but I had to visit a series of blogs to refresh my dark memories from past PostGIS installations done some years ago… So, here the few steps:

# become root
su -
# grab the PostgreSQL 9.3 server and PostGIS 2.1
yum install postgresql-server postgresql-contrib postgis

Now the server is installed but yet inactive and not configured. The next step is to initialize, configure and start the PostgreSQL server:

# initialize DB:
postgresql-setup initdb
# start at boot time:
chkconfig postgresql on
# fire up the daemon:
service postgresql start

A test connection will show that we need to configure TCP/IP connections:

# this will fail
psql -l
psql: could not connect to server: No such file or directory
    Is the server running locally and accepting
    connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?

So we enable TCP/IP connections listening on port 5432:

# edit "postgresql.conf" with editor of choice (nano, vim, ...),
# add line "listen_addresses = '*'":
vim /var/lib/pgsql/data/postgresql.conf
...
listen_addresses = '*'
#listen_addresses = 'localhost'         # what IP address(es) to listen on;
...

Now restart the PostgreSQL daemon:

# restart to re-read configuration
service postgresql restart

Check if the server is now listening on TCP/IP:

# check network connections:
netstat -l | grep postgres
tcp        0      0 0.0.0.0:postgres        0.0.0.0:*               LISTEN     
tcp6       0      0 [::]:postgres           [::]:*                  LISTEN     
unix  2      [ ACC ]     STREAM     LISTENING     2236495  /var/run/postgresql/.s.PGSQL.543

So far so nice. Still PostGIS is not yet active, and we need a database user “gisuser” with password:

# switch from root user to postgres user:
su - postgres
# create new DB user with password (will prompt you for it, choose a strong one):
createuser --pwprompt --encrypted gisuser

Finally we create a first database “gis”:

# create new DB
createdb --encoding=UTF8 --owner=gisuser gis

We enable it for PostGIS 2.1:

# insert PostGIS SQL magic (it should finish with a "COMMIT"):
psql -d gis -f /usr/share/pgsql/contrib/postgis-64.sql

That’s it! Now exit from the “postgres” user account a the “root” account:

# exit from PG user account (back to "root" account level):
exit

In case you want to reach the PostgreSQL/PostGIS server from outside your machine (i.e. from the network), you need to enable PostgreSQL for that:

# enable the network in pg_hba.conf (replace host line; perhaps comment IP6 line):
vim /var/lib/pgsql/data/pg_hba.conf

...
host    all             all             all                     md5
...

# save and restart the daemon:
service postgresql restart

Time for another connection test:

# we try our new DB user account on the new database (hostname is the 
# name of the server in the network):
psql --user gisuser -h hostname -l
Password for user gisuser: xxxxxx

Wonderful, we are connected!

# exit from root account:
exit
[neteler@oboe ] $

Now have our PostGIS database ready!

What’s left? Get some spatial data in as a normal user:

# nice tool
shp2pgsql-gui
shp2pgsql-gui

Using the shp2pgsql-gui

Next pick a SHAPE file and upload it to PostGIS with “Import”.

Now connect to your PostGIS database with QGIS or GRASS GIS and enjoy!

See also: https://fedoraproject.org/wiki/PostgreSQL

Colour blindness and grayscale previews in QGIS 2.4

Since QGIS 2.4 is nearing feature freeze it seems like a good time to start exploring some of the great new features in this release. So, let’s get started with my most recent addition to QGIS’ print composer… preview modes!

As every first year cartography text book will tell you, it’s important to know your target media and audience when creating a usable map. Some important considerations are whether or not your map will be photocopied or printed in black and white, and whether you need to consider colour blind map readers in your audience. In the past, designing maps with these considerations has been a time consuming, tedious process. You’d have to export your map, open it in another graphics editing program, apply some colour transform, work out what issues there are, flip back to QGIS, make your changes and repeat. If you’re working with a tight deadline it can be difficult to justify the time this all takes.

QGIS 2.4 will help to make this whole process a lot simpler. In the print composer there’s now an option to enable a number of different live “preview modes“. These include grayscale, monochrome, and two colour blindness simulations (Protanope and Deuteranope).

Composer preview modes in QGIS 2.4

Composer preview modes in QGIS 2.4

These preview modes are live, so you can continue to edit and tweak the colours in your composition while a preview mode is active! For a quick demonstration, let’s start with this creatively coloured thematic map:

bad_colored_map

While it might not be the most aesthetically pleasing map, at least the thematic colours can be easily matched to their corresponding values in the legend. Let’s see what would happen if we photocopied this map. This is as easy as activating the “Simulate photocopy (grayscale)” preview mode:

greyscalepreview

Hmm… not so usable now. The five thematic colours have been reduced to just three discernible colours. Oh well, at least we haven’t had to export our map to find this out, and it’s nice and easy to adjust the colours and composition to work for photocopies without having to leave QGIS to test the results!

Let’s see how this map would look to someone with colour blindness, by activating the “Simulate colour blindness (Protanope)” mode:

color_blindness

In this case, our map isn’t too bad. The different classes are still discernible and the map can be interpreted by someone with protanopia.

So there we have it – now it’s easy to determine how our map outputs will look under different circumstances and adjust them to suit! Composer preview modes will be a part of the upcoming 2.4 release of QGIS, which is due out at the end of June 2014.

Update:

This feature has also been added to the main map canvas.

Setting up PyCharm for PyQGIS and Qt

I have been asked a few times how to setup PyCharm so you are able to do PyQGIS development, or even PyQt because that is just as great. Rather then tell each person one at a time I thought I would throw it out as a blog post so everyone gets the benift.

The first thing we need to do is create a batch file that will load PyCharm and setup all the paths correctly. We have to do this on Windows as Qt and QGIS are not on PATH. QGIS also ships with it's own version of copy of Python so we need to tell PyCharm about it.

The batch file is as simple as this:

SET OSGEO4W_ROOT=C:\OSGeo4W
SET QGISNAME=qgis
SET QGIS=%OSGEO4W_ROOT%\apps\%QGISNAME%
SET QGIS_PREFIX_PATH=%QGIS%
SET PYCHARM="C:\Program Files (x86)\JetBrains\PyCharm 3.0\bin\pycharm.exe"

CALL %OSGEO4W_ROOT%\bin\o4w_env.bat

SET PATH=%PATH%;%QGIS%\bin
SET PYTHONPATH=%QGIS%\python;%PYTHONPATH%

start "PyCharm aware of QGIS" /B %PYCHARM% %*

Save this somewhere called pycharm-pyqgis.bat and run it.

This is a pretty basic batch file. It just sets the variables that we need for the QGIS and Qt libs, and also sets the PYTHONHOME to the QGIS version. The magic sause here is the set PATH, set PYTHONHOM, and set PYTHONPATH variables. You can just update the OSGeo4W_ROOT, and PYCHARM variables for your setup.

After running the batch we need to setup a Python interpreter in PyCharm. Click Configure -> Settings on the load page (or settings in the File menu). Search for Python Interpreters, and press the green add button and select local. Here we need to add the Python interpreter that we setup in our batch file. In the one I posted above it will be found at C:\OSGeo4W\bin\python.exe. Press Ok and PyCharm will find all the python paths it needs for the setup.

pycharm_python.png

Leave the settings dialog and create a new project.

pycharm_newproject.png

Remember to select the interpreter that we setup for the installed version of QGIS.

That is pretty much it. We can now create a pyqgis and pyqt app in PyCharm.

Lets give it a go

from qgis.core import QgsApplication
from PyQt4.QtGui import QDialog

GUIEnabled=True
app = QgsApplication([], GUIEnabled)

dlg = QDialog()
dlg.exec_()

app.exit(app.exec_())

Run it in PyCharm with Alt+Shift+F10. Good to go!

GDAL/OGR 1.11.0 released

The new version 1.11.0  of GDAL/OGR (http://www.gdal.org/) which offers major new features has been released. GDAL/OGR is a C++ geospatial data access library for raster and vector file formats, databases and web services.  It includes bindings for several languages, and a variety of command line tools.

Highlights:

More complete information on the new features and fixes in the 1.11.0 release can be found at http://trac.osgeo.org/gdal/wiki/Release/1.11.0-News

The new release can be downloaded from:

Composition styling in QGIS 2.2

Here’s a quick run-down on some new feature in QGIS 2.2 which I never got around to writing about before the release. I feel like I’ve got to give these features their due publicity before moving on to all the exciting new stuff which is being added for 2.4. So, without further ado, let’s take a dive into print composer shape and page styling in QGIS 2.2…

Shape styling

It’s no secret that QGIS has pretty impressive capabilities when it comes to cartographic styling of polygon features. Everything from line and point pattern fills, SVG image fills, gradients and even buffered gradients (new in 2.4 — more on that in a later post) can be used to shade polygons. That’s all in addition to the whole range of line styles which can be used to outline the edges of polygons. In QGIS 2.2 all these fill effects are now available for styling shapes in the print composer. What exactly does this mean?

Well, now you can draw a frame onto your print layout and style it with a gradient fill…

Gradient shape fill in composer

…or a line pattern fill….

Line pattern fill in composer

…or some crazy combination of everything…

Advanced fill in composer

It’s totally up to you how far you take this! Here’s a nice example of a map created in QGIS 2.2′s print composer using these new styling options.

Page styling for compositions

Why is this cool? Well, for a start, if we take a quick look at the QGIS map showcase on Flickr very few of the maps shown there have a white background. In previous versions of QGIS achieving a non-white background would require drawing a giant coloured rectangle over your whole composition, banishing it to the back of the stack, and then continually being annoyed by it getting in the way while you tried to work on the rest of the composition. Now, just like the shape styling described above, you can style the page background using any of the available options in QGIS for polygon fills!

Creating a composition with a black page background

Creating a composition with a black page background

It doesn’t end there though. Since the page background can now be styled like this, it’s also possible to have transparent or semi-transparent page backgrounds. I’ll show the result opened here in GIMP so that you can see the full transparency effect over GIMP’s checkerboard background pattern:

A composition exported with a transparent background

A QGIS 2.2 composition exported with a transparent background

Using a transparent composition background like this also allows for transparency effects in map layers to show through – so, for instance, if your map layer is set to 50% transparent then the resultant export from the composer will also be 50% transparent.

And now for the final stinger…

Have I mentioned yet that you can also use data defined symbology for both shape and page styling? No? Well, this was actually my main motivator in adding styling support to these elements. For a long time I’ve been wanting to create atlases which vary the page background based on attributes in the atlas coverage layer. Think flip-book style maps, where the page border is colour-coded to highlight areas that need attention. For example, areas with high rates showing with red borders, average rates with yellow, and low rates with green borders. Using a combination of page and shape styling, data defined symbology, and QGIS’ atlas features, this is now possible!

…And that (belatedly) wraps up my exploration of new features in QGIS 2.2. Next up I’ll start showcasing all the sweet new features which have landed for 2.4…

Getting started writing QGIS 2.x plugins

This post shows how to quickly and easily create a small QGIS plugin for counting the number of features within a vector layer.

To get started, you will need QGIS and Qt Designer (to design the user interface) installed. If you are on Windows, I suggest WinPython which provides Qt Designer and Spyder (a Python IDE).

The great thing about creating plugins for QGIS: There is a plugin for that! It’s called Plugin Builder. And while you are at it, also install Plugin Reloader. Reloader is very useful for plugin developers because it lets you quickly reload your plugin without having to restart QGIS every time you make changes to the code.

installPluginBuilder

Plugin Builder will create all the files we need for our plugin. Just start it and select a name for your plugin class (one word in CamelCase), as well as a name for the plugin itself and the plugin menu entry (can be multiple words). Once you press Ok, you’re asked to select a folder to store the plugin. You can save directly to the QGIS plugin folder ~\.qgis2\python\plugins.

pluginBuilder

Next, open the newly created folder (in my case ~\.qgis2\python\plugins\BuilderTest). Amongst other files, it contains the user interface file ui_buildertest.ui. Our plugin will count the number of features in a vector layer. Therefore, it needs a combobox which allows the user to select a layer. Open the .ui file in Qt Designer and add a combobox to the dialog. Change the object name of the combobox to layerCombo. We’ll later use this name in the plugin code to add items to the combobox. Save the dialog and close Qt Designer.

qtDesigner

Now, we need to compile the .ui and the resources.qrc file to turn the dialog and the icon into usable Python code. This is done on the command line. On Windows, I suggest using the OSGeo4W Shell. Navigate to the plugin folder and run:

pyuic4 -o ui_buildertest.py ui_buildertest.ui
pyrcc4 -o resources_rc.py resources.qrc

If you enable and run the plugin now, you will already see the dialog but the combobox will be empty. To populate the combobox, we need to write a few lines of code in buildertest.py. First, we’ll fetch all loaded layers and add all vector layers to the combobox. Then, we’ll add code to compute and display the number of features in the selected layer. To achieve this, we expand the run() method:

def run(self):        
    # show the dialog
    self.dlg.show()

    layers = QgsMapLayerRegistry.instance().mapLayers().values()
    for layer in layers:
        if layer.type() == QgsMapLayer.VectorLayer:
            self.dlg.layerCombo.addItem( layer.name(), layer ) 
         
    # Run the dialog event loop
    result = self.dlg.exec_()
    # See if OK was pressed
    if result == 1:
        # do something useful 
        index = self.dlg.layerCombo.currentIndex()
        layer = self.dlg.layerCombo.itemData(index)
        QMessageBox.information(self.iface.mainWindow(),"hello world","%s has %d features." %(layer.name(),layer.featureCount()))

When you are done with the code, you can use Plugin Reloader to load the new version. When you start the plugin now, the combobox will be populated with the names of the vector layers in your current project. And on pressing Ok, the plugin will compute and display the number of features.

builderTEst

builderTestResult

For more information on PyQGIS and more code samples I warmly recommend the PyQGIS Cookbook. Have fun!


A QGIS class room setup on Windows

Somebody in my neighbourhood is Windows Administrator on a ‘Middelbare School’ here in Haarlem, my hometown. The school, het Mendelcollege, received a (Q)GIS intro by Margit Stapel of GisWijzer who is doing introductions for 10 – 14 year old childer with GIS. The school received this course from a GIS professional as part of the […]

South-East QGIS User Group – Writeup

Since helping to organise the inaugural meeting in September 2013, this was the first UK QGIS South-East UG meeting which piggy-backs off the success of the Scottish and Welsh UG meetings.

Putting an agenda together isn’t the easiest thing to do at the best of times and especially given that the use of QGIS here in the UK is still in its infancy but thankfully without much need for pleading many kind people came together to help out and make the day a great success.

Imperial College hosted the event for us and everyone one agreed that the facilities were fantastic. A special thanks needs to go to Claudia Vitolo for arranging everything for us at Imperial. There was a good turnout with about 55 people turning up, with a real mix of public, private and academic backgrounds.

imperial_1

David McDermott started off proceedings with a talk about Atlas and Map Production. He cleanly illustrated to the audience through screenshots how Surrey Heath Borough Council are using this fantastic feature of 2.2 to produce lots of maps, quickly, efficiently and importantly eye-pleasing.

imperial_2

Mike Saunt demonstrated through a mixture of presentation and live demo a series of tweaks within QGIS and using a bit of SQL in PostGIS, how QGIS can be an Enterprise GIS tool. For those in the audience that new to QGIS or looking for alternative GIS solutions were keen to ask questions about the QGIS/PostGIS architecture which Mike was very happy to answer, sighting many case examples.

imperial_3

Jerry Clough gave a well received talk on OpenStreetMap and promoted a lot of conversation. Jerrys’ talk was a real mixed bag of factoids and tips on OSM in general and using it within QGIS.

Andrew Bell gave the audience a treat by demonstrating how with some simple PostGIS SQL you could within QGIS draw a line or route (from A to B) which would automatically buffer and select features from the Ordnance Survey PoI (Points of Interest) layer that fell within the buffer. All very simple but very effective process. Andrew admitted that this had a lot of scope and could be adapted for Emergency Planning for example.

View presentation here

The afternoon sessions saw two workshops;

Pete Wells from Lutra gave a whistle stop run through of using Python and QGIS, and went as far as producing a very simple plugin all within the space of an hour and ten minutes. It was a well attended talk and the sort of workshop that future user groups should try to repeat.

The Ordnance Survey did an Introduction to QGIS using OS Opendata and was equally well attended as Pete Wells workshop, as both workshops ran at the same time. The talk was loosely based on the successful OS MasterClasses that have been run over the past few years.

The schedule of the day quickly slipped, mainly due to the great audience participation at the end of the presentations. As a result the afternoon workshops, ‘its your floor’ and discussion sessions were shortened so that a 4pm finish was achievable.

Its your floor was a bit of a wild card slot in the days agenda. Prior to the event the attendees were asked  if they wanted to take to the stage and chat about what they were doing to QGIS, effectively 5 slides in 5 minutes. Two brave souls stepped upto the mark and gave informative but lightning talks about what they had been up to. This is certainly a part of the agenda that the South-East region will be repeating again.

The day ended with a lively debate about the role and future of the UK QGIS user group and it might be that moving forward such a debate becomes an earlier item on the days agenda.

One of the discussion points was on the cost of running future events. Based on an online poll conducted earlier on this year and feedback from the Scottish group, it was clear that for the group to continue future events will probably longer be free and as such a minimal donation would be required to attend. The true cost of hosting an event is probably more than most imagine. The single biggest cost is catering, in the case of this meeting and the inaugural meeting back in September 13, the combined cost just for catering was in excess of £1400. Luckily in both cases and in fact in all of the user group meetings that have occurred catering and venue hire costs have been met through sponsorship. However such kind support from private companies will not last indefinitely. The exact minimum donation cost may vary from event to event, depending on venue hire costs and catering.

Over a series of discussion topics a few themes kept on popping up which put into question the role of the user group. Behind the scenes of the user group, as with any user group or community there are also people busy working away to do all sorts of things in the background. The user group has a loose working community which is referred to as regional leads but in fact these regional leads are not standing alone but a few people supporting them. This working group has been discussing how we can work more closely with the core QGIS project and hopefully soon we will be able to clearly define how we achieve this. Where this thought process is going is that the role of the user group is just that, a user group and not a QGIS developer group. Clearly some people within the wider UK QGIS UG will be more developer minded than others and as such would be encouraged to participate the development of QGIS. Others may want to help out with updating manuals or bug hunting. While others might not be interested in any of the above and just want to create maps, data or GIS processes and share these with the group which should equally be encouraged.  We as a user group should be there to encourage any of the above users.

Simon Miles


Slides – Scottish QGIS User Group Meeting

An introduction from Ross McDonald to the inaugral QGIS user group meeting in Scotland.

Neil Benny from thinkWhere getting passionate about QGIS and open source spatial software.

Martin Dobias from Lutra showing us the super performance enhancements coming in the next version of QGIS.

Charley Glynn from Ordnance Survey demonstrating some of the map eye candy they’re producing with QGIS.

Pete Wells from Lutra showing us how to use Python with QGIS.

Videos of the talks will be posted here including Heikki Versanto showing how to connect to a huge variety of data sources.


Workshop at FOSS4G 2014: Spatio-temporal data handling and visualization in GRASS GIS 7

Drowning in too many maps? Have some fun exploring fascinating geometries of changing landscapes in Space Time Cube and creating 2D and 3D animations from time series of geospatial data. Learn about the new capabilities for spatio-temporal data handling in GRASS GIS 7 (http://grass.osgeo.org/grass7/) and explore various techniques for dynamic visualizations.

First, we will introduce you to GRASS GIS 7, including its spatio-temporal capabilities and you will learn how to manage and analyze geospatial data time series. Then, we will explore new tools for visualization of spatio-temporal data. You will create both 2D and 3D dynamic visualizations directly in GRASS GIS 7. Additionally, we will explain the Space Time Cube concept using various applications based on raster and vector data time series. You will learn to manage and visualize data in space time cubes (voxel models). No prior knowledge of GRASS GIS is necessary, we will cover the basics needed for the workshop. All relevant material including an overview of the tools and hands-on practical instructions along with the sample data sets will be available on-line. And, by the way, GRASS GIS is a free and open source geographic information system (GIS) used for geospatial data management, analysis, modeling, image processing, and visualization which runs on Linux, MS Windows, Mac OS X and other systems.

Presenters: Vaclav Petras, Anna Petrasova, Helena Mitasova, Markus Neteler

When:  FOSS4G 2014, Sept 8th-13th 2014, Portland, OR, USA

Register at: https://2014.foss4g.org/schedule/workshops/#wshop-526

QGIS PT users group: Portuguese speaking community

It’s with an enormous pleasure that we announce what we believe to be a very important step for the QGIS Portuguese speaking community, the creation of the QGIS PT users group. The QGIS PT users group arise from the notorious growth of QGIS usage  in Portugal, with the objective of become a platform for sharing […]

Using OSM POIs in QGIS

Extracting POIs from OpenStreetMap is reasonably simple using Overpass API. A very convenient way to construct the query is to use a query builder which allows you to select the area of interest and builds queries for different servers.

xapi_query_builder

Of course you can fine-tune the query further. For example, you can add multiple key-value pairs to the query. I used the following query to select all Billa supermarkets:

http://www.overpass-api.de/api/xapi?*[shop=supermarket][name=Billa][bbox=15.96725,48.0432,16.79947,48.40915]

Note the * in the query? It means that I’m querying all kinds of features: nodes, ways, and relations.

Save the server response to a .osm file. This file can be loaded into QGIS using simple drag-and-drop or Add Vector Layer. A dialog will open where you can select the type of features you want to load from the file. You can simply use Select All and OK to load everything.

add_osm_file

My supermarket POIs came in two types: points and multipolygons. To style them both with nice supermarket SVG icons, I decided to use a Centroid fill with the SVG marker for the polygon layer:

osm_pois_billa

Open data and open source GIS … nice :-)


Topology in QGIS

Introduction

Topology rules define the permissible relationships of features within a given GIS layer or between features in two different GIS layers. An example is that features in a road dataset must be connected to other roads at both ends, unless the road is specified as a dead end street.

Advantage of topology over queries

A lot of the checks that topology rules carry out could be achieved using spatial queries. You may have to use queries if the GIS software you’re using doesn’t have a topology feature.

Topology rules have the advantage that they only need be created once and then they can check your work as you go.

Queries would need to be re-created each time they are run. They can be saved, depending on the GIS being used, but this is still more time consuming and it is a task that must be carried out separately at the end of a work session.

Rules

QGIS 2.2 topology tool has the following rules pre-defined:-

  • End points must be covered by (e.g. a railway line usually begins and ends at a station)
  • Must contain (e.g. a building polygon must contain at least one address point seed)
  • Must not have dangles (a line must begin and end at another line)
  • Must not have duplicates (each feature should be unique, e.g. postcode areas)
  • Must not have gaps (e.g. administrative area polygons cannot have gaps)
  • Must not have invalid geometries
  • Must not have multi-part geometries (each feature should be a separate entry)
  • Must not overlap (e.g. administrative area polygons cannot overlap each other)
  • Must not overlap with (a feature from layer must not overlap with another layer)

Example 1 – Roads must not have dangles

The following example uses the “Must not have dangles” rule to identify polylines from a roads dataset that are not snapped to other lines. Roads usually begin and end at a junction with another road, so this is a useful rule to identify where lines were not correctly snapped together.

To create and validate a Topology Rule

  • Open the Topology Panel, by selecting Vector menu, Topology Checker, Topology Checker
  • The Topology Panel appears in the lower right corner of the QGIS desktop window

Image

  • Press the Configure button to open the Topology Rule Settings dialog
  • The top of the box will have 2 or 3 pull down boxes depending on the layer and rule that is chosen. Use these to build the rule and then press the Add Rule button.

Image

  • Press OK when done, the dialog box closes and the window returns to the QGIS Desktop.
  • Press either the Validate All or Validate extent, depending on whether you wish to validate the entire dataset or just the current view extent.
  • The errors will be listed. Double click on a row will make the map window zoom and pan to the error.

Image

 


Formação em SIG Open Source com QGIS (Quantum GIS) em Moura, 28-29-30 Maio 2014

A Faunalia, em colaboração com a ENCPB (Escola Nacional de Caça, Pesca e Biodiversidade), Comoiprel e Câmara Municipal de Moura, organiza um curso de SIG Open Source com QGIS (Quantum GIS) nos dias 28-29-30 Maio 2014. Para informações e inscrições contactar: ENCPB (Escola Nacional de Caça, Pesca e Biodiversidade) E-Mail: encpb.moura@gmail.com Telefone: 285251354   Programa […]

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:

/images/qgs_prefix.png

As far as I can tell, reservation of prefix names is no longer possible. For a view into what it was like back then, take a look at the Internet Archive:

http://web.archive.org/web/20030303075955/http://www.trolltech.com/documentation/naming.html

Although the choice of prefix wasn’t based on technology or discipline, years later it seems to fit…

Reporting back from the Vienna Code Sprint

Today was the last day of the Vienna code sprint which brought together OSGeo developers from many projects. It’s been a great week thanks to organizers and sponsors!

The QGIS team was extremely busy working on the project’s web infrastructure (e.g. new plugins.qgis.org website) as well as hunting down and fixing bugs.

Check out some impressions on twitter.

qgis23_vienna

More pictures on the official blog: vienna2014.sprint.osgeo.org


OS OpenData Workshop – QGIS in the Classroom

Last week I attended an Ordnance Survey OpenData MasterClass in Exeter. This was one of a series of seven masterclasses that the Ordnance Survey were running across the country. They were aimed at letting people know how to get the best of the  OpenData products that they provide.

The workshop was delivered in a format of combining theory and practical sessions. They were aimed at people of various experience; from those new to working with location data to the more advanced users wanting to brush up on their skills.

What was encouraging from a QGIS point of view was that a lot of the course was taught using QGIS 2.0.  After an interesting introduction to the history and current standing of OpenData by Ian Holt we were given our first taste of QGIS. Ably led by Steve Kingston we were shown:

  • How to navigate around QGIS;

  • Import a range of vector and raster datasets (thankfully pre-downloaded);

  • Build virtual rasters (very useful if you’re dealing with lots of OS tiles);

  • Merge shapefiles into one layer

  • Create thematic maps from LSOA boundaries and ONS data (like the one below)  - here I learnt  you can now load non-geographic data from a csv straight into QGIS without using a csvt file, yay!

imd_compressed

After Lunch and a quick insight by Chris Parker  into the next Geovation Challenge , Chris Wesson from the Carto Design team at the OS gave a cartographic design workshop. This started off with a talk about the basic design principles behind cartography and how you should bear these in mind when making a map.

He then showed us how to import vector map district vector data and then style these in a various ways –  I particularly found his tips on creating road casing useful. Some of the maps being were produced were of a really good standard, especially when you this was many people’s first time using a GIS of any sort.

I thought that this was a really worthwhile experience and would recommend going to one if you get the chance in the future (according to their website there are still masterclasses to come in York and Nottingham). I learnt a fair bit myself as I always think it’s useful to watch someone else use a product that you’ve used in isolation. They might do something that you’ve never seen before that’s loads quicker or show you a hidden feature you’ve not come across.

It was encouraging to see people of various backgrounds present, parish councils in particular. As someone who works for a local authority that has many Parishes i’m very keen to promote the use of open data by parishes and local groups and get them using QGIS, etc

In the New Year I’m going to look into having a QGIS South West event and hope to reach out to all  types of QGIS users across the region. I’ll keep you posted on the exact details via the Google+ group but if you read this and are in or around the South West and want to share your experiences of using QGIS (no matter how big or small) then please get in touch.

That’s it for now. Just leaves me to thank all the people that made the OS Masterclasses possible I’m sure they’ve been a success so hopefully they’ll be even more next year to look forward to!
Matt


  • <<
  • Page 2 of 57 ( 1138 posts )
  • >>

Back to Top

Sponsors