QGIS

Filter only visible legend items in QGIS

To only show legend items that appear in the map, QGIS has a filter function to easily do this.

 

Go to the filter icon above the layers panel, and check ‘Filter Legend by Map Content’

Likewise in the Map layout, the legend can be filtered by the checking the box ‘Only show items inside linked maps’

Upload Shapefiles to SQL Server Spatial in QGIS

To import Shapefiles into SQL Server without the use of scripts such as Ogr2ogr, we can easily use QGIS instead. Make sure you have SQL Server and SQL Server Management studio installed.

Open QGIS and in the Browser panel add a new connection by right clicking on MSSQL.

Enter a connection name and enter the server name used in SQL Server. Click ‘List Databases’ to see the tables.

Once the SQL server connection has been established, you can drag shapefiles and other GIS formats directly into the SQL server connection.

 

Change the Levels of Features in the same Layer in QGIS

We will move a feature above/below another feature in the same layer in QGIS. In this example we want to move the green hatched polygon above the pink hatched polygon.

Open the properties for the layer and go to the Advanced drop down.

Change the level number of the features you want to move above a higher number than the features you want to move below.

In this example, Layer 0 column refers to the hatching pattern, and the Layer1 column refers to the outline of the polygon. Click apply and the features order will rearrange.

 

How to add a legend to a map in QGIS

Open composer and click on the “add legend” button as shown below.

add legend button crop

Once the legend has been added to the map, you can add and remove map layers from the legend as shown below.

add items to legend

You can also add a frame around the legend box and change the background color to improve the visibility of the legend items if necessary.

frame and background color small

Make text standout in QGIS

To make text standout from other map features we can either add a rectangle background or a buffer behind the text.

plain text

To change the properties of the text labels, double click on the layer containing the text > Labels > Background>Draw Background as shown below.

background on text

background on text 2

Alternatively you can add a buffer around the text. This option reduces the amount of map features being covered by the text background.

Double click on the layer containing the text > Labels > Buffer>Draw Text Buffer as shown below.

buffer on  text

buffer on  text 2

These text backgrounds and buffers can be any color. It is ideal to choose a color which contrasts well with text color.

How to Add a Scalebar to a Map in QGIS

Open composer and the actual scale of the map can be set by selecting the map area and setting the scale in ‘Item Properties’ shown below.

set scale

Click on the “Add new scalebar” button on the left side bar.

add scalebar

Once the scalebar has been added, you can modify the number of segments and height. The units can also be modified in the item properties.

modify scalebar

To add a numeric scale click on the “Add new scalebar” button again and place under the first scalebar. Another scalebar will appear. Go to the Item Properties menu again and under main properties change the ‘Style’ to Numeric and uncheck the ‘Background’ box to make the box transparent as shown below.

numeric scale

Search for an attribute in a table in QGIS

In this example we will be searching for a city in a cities layer. Open the table by clicking the ‘Open Attribute table’ icon shown below.

open table clip

Below the table click on ‘column filter’ > select the column you want to search through. In this case it is the column called ‘name’

column filter

Type in the name of the city you want to find and click apply. Your search can be case sensitive if desired.

search sydney clipped

In this case our search query came up with 2 results as shown below

search result clipped

 

Georeferencing Image files in QGIS

In this example we will georeference a jpeg map of Australia.

FREE MAP OF AUSTRALIA

To georeference this map we need some common points to reference the image to. I will use a country layer (shown below) to match points to locations on jpeg map.

just boundaries

Next start Georeferencing by going to the raster menu > Georeferencer

Open a raster by clicking the button shown below.

start georef

Once the raster has been opened click on a point on the image which can be easily located on the country boundaries layer

click on first point

A popup will showup. select “from map canvas” and find the same point in the country boundary layer.

first point entered

Click OK in the Georeferencer and the point will be added as shown above.

Click on a selection of points spread out over the area of interest like my example below.

digitized points

Once the points have been added, got to file menu >  start georeferencing

georeference settings

Specify the transformation settings like above. Use a Projective transformation type is the image needs to be rotated and re-sized. A “Linear” transformation could be used in this example as the image only needs to be re-sized and not rotated. For output raster choose a suitable file name and for Target SRS choose your projection system.

finish

After you click OK the georeferenced image should display in your layers in the correct position.