[GIS] How to create a custom coordinate grid in the QGIS 2.14.2

grids-graticulesqgis

I want to create a custom grid different from latitude / longitude, with letters and numbers on the axes.

X = A, B, C, D, D, …
Y = 1, 2, 3, 4, 5, …

A B C D E

1

2

3

A B C D E

I also intend to serve to use the data in an overview in the print the composer to give the location of the map, "A – 1, or C – 5, etc)

Best Answer

In the print composer, create three grids on your map item:

  • one for the actual grid lines
  • one for X values (to disable grid lines, set them to "No pen")
  • one for Y values (idem)

For Y coordinates, you want to see 1 2 3 4 ... Depending on your max and min coordinates, and interval, use the Custom format in the Draw coordinates submenu. You can add an offset to show the values in the middle of the grid lines. The @grid_number variable represents the value of the X and Y at the grid's position.

For example, if your coordinates start at 49.5 and have an interval of 0.25, you can write (@grid_number - 49.5) / 0.25 + 0.5 in the Custom field.

For X values, you want to see A B C D E. You do the same but you take a substring of the alphabet. It also depends on your bounds. substr('ABCDEFGHIJKLMNOPQRST', (@grid_number - 2.5) / 0.5 + 0.5, 1)

I don't know if it's possible to automatically retrieve the X_max, Y_max and interval values in variables to avoid hardcoding them.

Here is an example for Belgium where both lat/long and ABC/123 coordinates are shown:

Belgium

I've uploaded the sample qgs project here if you want to have a look at it.