Configure editing form widgets using PyQGIS
As I was preparing a QGIS Project to read a database structured according to the new rules and technical specifications for the Portuguese Cartography, I started to configure the editing forms for several layers, so that: Make some fields read-only, like for example an identifier field. Configure widgets better suited for each field, to help the user and avoid errors. For example, date-time files with a pop-up calendar, and value lists with dropdown selectors.
Using QGIS from conda-forge
QGIS recipes have been available on Conda-forge for a while, but now, that they work for the three main operating systems, installing QGIS from Conda is s starting to become a very reliable alternative to other QGIS distributions. Anyway, let’s rewind a bit… What is Conda? Conda is an open source package management system and environment management system that runs on Windows, macOS and Linux. Conda quickly installs, runs and updates packages and all their dependencies.
Getting multipolygon vertexes using PostGIS
Today I needed to create a view in PostGIS that returned the vertexes of a multi-polygon layer. Besides, I needed that they were numerically ordered starting in 1, and with the respective XY coordinates. It seemed to be a trivial task – all I would need was to use the ST_DumpPoints() function to get all vertexes – if it wasn’t for the fact that PostGIS polygons have a duplicate vertex (the last vertex must be equal to the first one) that I have no interess in showing.
Hack to adjust map symbols location in QGIS
Now and then I get too many map symbols (points) in the same place, and I thought how nice it would be if we could drag n' drop them around without messing with their geometries position, just like we do with labels. That thought gave me an idea for a cool hack. Choose your point layer and start by creating two new fields called symbX and symbY (Type: Decimal number; Size: 20; Precision: 5).
Calculate polygon centroid's coordinates
I had the need to add columns with the coordinates of polygons centroids. I came up with the following expressions to calculate X e Y, respectively: [code] xmin(centroid($geometry)) ymin(centroid($geometry)) [/code] The expression seems quite simple, but it toke me some time before I realize that, not having a x(geometry) and y(geometry) functions, I could use the xmin() and ymin() to get the coordinates of the polygons centroids. Since this wasn’t the first time I had to use this expressions, this post will work as a reminder for the future.
Labels leading lines with QGIS and Postgis
Recently I had the need to add labels to features with very close geometries, resulting in their collision. Using data-defined override for label’s position (I have usedlayer to labeled layer plugin to set this really fast) and the QGIS tool to move labels, it was quite easy to relocate them to better places. However, in same cases, it was difficult to understand to which geometry they belonged. I needed some kind of leading lines to connect, whenever necessary, label and feature.
Multiple format map series using QGIS 2.6 – Part 2
In my last post, I have tried to show how I used QGIS 2.6 to create a map series where the page’s orientation adapted to the shape of the atlas features. This method is useful when the final scale of the maps is irrelevant, or when the size of the atlas elements is similar, allowing one to use a fixed scale. On the other hand, when using a fixed scale is mandatory and the features size are too different, it is needed to change the size of the paper.
Multiple format map series using QGIS 2.6 - Part 1
As always, the new QGIS version (QGIS 2.6 Brigthon) brings a vast new set of features that will allow the user to do more, better and faster than with the earlier version. One of this features is the ability to control some of the composer’s items properties with data (for instance, size and position). Something that will allow lots of new interesting usages. In the next posts, I propose to show how to create map series with multiple formats.
Map corner coordinates in QGIS
Some time ago in the qgis-pt mailing list, someone asked how to show the coordinates of a map corners using QGIS. Since this features wasn’t available (yet), I have tried to reach a automatic solution, but without success, After some thought about it and after reading a blog post by Nathan Woodrow, it came to me that the solution could be creating a user defined function for the expression builder to be used in labels in the map.
Please use the "IN" operador
It’s not the first time I see people that, to select feature by their fields values, use expressions like this: [code language=“SQL”]“field” = ‘value1’ OR “field” = ‘value2’ OR “field” = ‘value3’ [OR …][/code] A more practical and pretty way of doing this is by using the IN operator instead. [code language=“SQL”]“field” IN (‘value1’,‘value2’,‘value3’[,…])[/code] This operator is available in almost every GIS software I know. In QGIS, it can be used even if there isn’t a small little button to click.
Old map in QGIS
Inspired in a post by Anita Graser, I’ve tried to use QGIS to create a Cascais’s old looking map, as if it have been drawn by hand in a methodical way. Defining the styles I have started by defining the styles for each elements to represent. Buildings To fill the buildings, I have tried to use a color that reminds me the portuguese roofs, similar to the color commonly used in old maps of cities, with a slightly darker outline of the same color.
Substituir strings na tabela de atributos do QGIS
Hoje, ao rever uma camada vectorial de distribuição de fauna com interesse para a conservação com a nossa bióloga de serviço, Sara Saraiva, tive necessidade de corrigir (em todas as linhas de determinado atributo) o nome “Aquila fasciatus”, substituindo-o por “Aquila fasciata”. Devido à opção tomada na organização dos dados, cada polígono continha uma listagem de espécies que nele ocorrem, e o nome a corrigir encontrava-se no meio da mesma. A correcção teria de ser feita sem alterar os restantes nomes.