Uncategorized

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.

Draw lines specifying length and angle

This function in QGIS allows for CAD-like drafting.

Go to View menu>Panels and show “Advanced Digitizing Panel”

advanced draw

Click the “Add feature” icon and click the start point on the map.

type the “d” key on your keyboard and enter the distance. press enter. This will set the distance.

type the “a” key on your keyboard and enter the angle. press enter. This will set the angle of the line.

How to make your text labels standout on an aerial photo map

text color black

When creating a map with an aerial photo as it’s base, it is important to make the text labels stand out as plain text can get easily drowned out by the background colors.

text color Yellow

Yellow is often an appropriate color when the aerial photo is mainly made up of darker colors.

text color buffer

However yellow may not be very visible on light colors like white. A text buffer can overcome this issue. In the example above, I have used yellow text with a black buffer but black text with light buffer is just as effective.

text color curved

When labeling curvy features such as rivers and roads it is better to curve the text so that it sits neatly along the feature. This function in QGIS is found in the placement option in the layer properties as shown below.

text placement qgis

 

These are some tips to make your aerial photography maps easier to read and interpret. If you have any comments please let me know below.

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.

Creating a new polygon shapefile in QGIS

Here we will create a polygon layer by tracing sports fields and adding attribute data.

Go to the layer menu>New>New Shapefile layer…

create shapefile

In this example we will trace the boundaries of sporting fields.

  • Select Polygon
  • Select the appropriate coordinate reference system
  • Create a new Attribute called “Sport” (this will be the type of sport played)
  • Select type “text data”
  • Click “Add to attribute list”
  • Create another attribute called “Irrigation” following the same steps
  • Lastly create an attribute called “Area” this time select decimal number under Type.

new vector layer

  • Finally click OK.
  • Save the file as “Sports_fields” (you always need underscores instead of spaces)
  • The new layer will appear in the layer menu
  • Click on the layer and toggle editing with the pen icon

start editing

  • Go to the edit menu > add feature
  • Click at each corner of the field and right click to finish
  • Fill in the details as shown below.

add feature

  • Create features around the other fields giving them different attribute data.

digitized sports fields

  • When finished, go to the layer menu > save layer edits
  • Toggle the edit icon to stop editing