[GIS] Adding graticules to the edge of the map only in QGIS

coordinatesqgisqgis-2

I would like to add graticules to a map, once it is in the 'print composer', on the border of the map, and not on the frame (my map insists on being smaller than the frame). I have managed to add a lat/long grid over my map, and the grid lines are transparent. I do not want crosses or grid lines, just tick marks on border.

I am using QGIS Dufour (2.0) or Valmiera (2.2).

Can any one help?

Best Answer

It is possible to get tick marks just along the edge of the map object's frame, just a little fiddly:

  1. Check 'Show Grid' in the map's Item Properties.
  2. Set the grid interval to whatever you want (some multiple of your real world units e.g. 1,000m or whatever). This will give you a complete grid, but don't worry - we'll fix that...
  3. Set 'Frame Style' to 'No Frame' (default).
  4. Click on 'Line Style' to get the Symbol Selector dialog. On the left-hand side of the dialog note the 'Symbol layers' pane.
  5. Select the item labelled 'Simple Line' and click the 'Symbol layer type' drop-down list on the top right (currently also set to 'Simple Line') and change it to 'Marker Line'. You will get a load of red dots.
  6. In 'Marker Placement' select 'on last vertex only'.
  7. Back in the Symbol layers pane, select the item marked 'Simple marker' (expand the 'Marker Line' item if necessary using the little + next to it). Change the marker to a vertical line and set its angle to 90 degrees (this is important).
  8. You are now halfway there (trust me!). Go back to the 'Symbol layers' pane and click on the very first item 'Line' (the parent in the symbol hierarchy). This enables the grey-out plus button at the bottom of the dialog box, turning it green. Press the green + button.
  9. Now repeat the steps above except this time choose 'on first vertex only' in step 6. When you are done click OK at the bottom right.

You should now have tick marks on just the edge of the map object's frame. You can change the size and thickness of the by going to Simple Marker item (last item at the bottom of each of the 'Marker line' hierarchies) and playing with 'Size', 'Colors' and ;Outline width' etc to make it look how you want.

As you have discovered, the map frame works by automatically clipping everything to its limits, this means that you can only have the tick marks pointing inwards, unless you get even more devious! To get them pointing out do this:

  1. Create a second map object and using the position and size controls, set it to exactly the same size and position as the map object with the tick marks. (it will temporarily cover it).
  2. You now need to align the data. Set the extents of the new map to match your original one. Make a note of the scale.
  3. Go to 'Position and size' and set the reference point to be the middle of the new map. adjust the Width and height so that the new map fits neatly within the tick marks of the first one. Do NOT pull the map manually with the handles.
  4. Your extent and scale will now have changed on the new map. Set ONLY the scale to the value you noted in step 2.
  5. Check 'Lock layers for map item' on the new map object.
  6. Switch back to main QGIS window and turn off all your layers until the canvas is blank.
  7. Switch back to the Map Composer and check 'Lock layers for map item' on the original map object (the one with the tick marks.

You now should have a map window showing your data and tick marks on the outside. You can go ahead and turn your layers back on now without upsetting your arrangement because you locked the layers of the tick-map item. I think it looks goof to add a frame to the inner map object (not with map's 'Show grid' but with the standard 'Frame' option towards the bottom of the Item properties controls.