Add Grid to Layout
ដាក់ក្រឡាចត្រង្គកូអរដោនេ — រួមទាំងក្រឡាចត្រង្គ MGRS ពេញលេញ — លើផែនទីក្នុង layout ពីផ្ទាំងតែមួយ។
- រកឃើញនៅឯណា
- Processing ▸ Toolbox ▸ KGA Toolbox ▸ KGA Mapping ▸ Add Grid to Layout
- លេខសម្គាល់ algorithm
- kga:add_grid
- ប្រភេទឧបករណ៍
- Interactive dialog — modeless, needs the QGIS window and a print layout
ទិដ្ឋភាពទូទៅ
QGIS can already do all of this. What it cannot do is do it quickly: the grid lives in the layout designer's item properties panel, behind Grids, a + button, a Modify grid… button and five collapsible sections, and the interval, the frame, the label format and each side's label orientation are in four different places. This is the same settings in one form, with a Suggest button that works the interval out from what the map is actually showing.
It also edits the grids a map already has, not only new ones, so it is the faster way back in when an interval turns out wrong at print size.
And it draws an MGRS grid, which QGIS cannot do at all: there is no MGRS anywhere in the QGIS API.
ប៉ារ៉ាម៉ែត្រ
Which map
The algorithm takes no Processing parameters — running it opens the window. The controls below are the window's, and rows it does not need are hidden.
| ផ្ទាំងគ្រប់គ្រង | ប្រភេទ | តម្លៃលំនាំដើម | ការពិពណ៌នា |
|---|---|---|---|
| Layout | Combo box | the layout whose map is selected | Every print layout in the project. The Open button beside it opens that layout in the designer, or brings its designer to the front. |
| Map item | Combo box | the selected map | The map items of that layout, by name. |
| Grid | Combo box | <Add a new grid> | Also lists the grids the map already has, as Edit: <name>. Picking one loads its settings into the form. |
| Grid name | Text | Grid | What the grid is called in the designer's grid list. A name already on that map gets 2 appended rather than overwriting. |
| Preset | Combo box | Start from... | Fills the whole form in one pick: Thin black graticule, Exterior ticks, labels outside, Zebra frame, labels outside, Lat/long graticule in degrees, Crosses, labels inside. Below the separator sits MGRS grid, which is not a preset but a set. |
| Grid interval | Combo box | Automatic | MGRS set only. Automatic works the spacing out from the map extent; 10 km, 1 km, 100 m, 10 m and 1 m name it instead, which is what a sheet drawn to a stated scale needs. |
| Also add | Two check boxes | both off | MGRS set only. 1 km mesh adds the fine mesh of a 1:50,000 sheet; Labels inside too repeats the numbers against the inside of the frame. |
| Positioning | Three toggle buttons | Two strips per axis, at 1/4 and 3/4 | Where the interior number strips go. Enabled once Labels inside too is ticked. |
| 100 km letters | Combo box | In the margin | MGRS set only. In the margin, outside the numbers or Inside the map, against the frame. |
Grid tab
| ផ្ទាំងគ្រប់គ្រង | ប្រភេទ | តម្លៃលំនាំដើម | ការពិពណ៌នា |
|---|---|---|---|
| Grid type | Combo box | Solid lines | Solid lines, Crosses, Markers, Frame and labels only. |
| Coordinate system | CRS selector | Not set | Not set grids the map in its own CRS. Set it to EPSG:4326 for a latitude/longitude graticule over a projected map. Changing it re-suggests the interval. |
| Interval units | Combo box | Map units | Map units, Millimetres on the page, Centimetres on the page, Fit the page automatically. |
| Interval | Two numbers + Suggest | 1000 | X and Y spacing. Suggest fills both with a round number — 1, 2, 2.5 or 5 times a power of ten — that cuts the map into about five columns and rows. |
| Offset | Two numbers | 0 | Shifts the grid origin, for lines that have to land on a particular coordinate. |
| Spacing on the page | Two numbers | 50–100 mm | Fit the page automatically only. QGIS recomputes the interval at each render so the spacing stays between these two widths. |
| Line colour / Line width | Colour button, number | Black, 0.2 mm | Opacity included. The colour is also the marker colour. |
| Cross size / Marker size | Number | 3 mm / 2 mm | Crosses and markers only. |
Frame tab
| ផ្ទាំងគ្រប់គ្រង | ប្រភេទ | តម្លៃលំនាំដើម | ការពិពណ៌នា |
|---|---|---|---|
| Frame style | Combo box | Exterior ticks | No frame, Zebra, Zebra (nautical), Interior ticks, Exterior ticks, Interior and exterior ticks, Line border, Line border (nautical). |
| Frame size | Number | 2 mm | How far the frame or the ticks reach out from the map. |
| Frame line thickness / colour | Number, colour button | 0.3 mm, black | |
| Fill colour 1 / 2 | Colour buttons | Black / white | The two zebra bands. Shown for the zebra styles only. |
| Draw on | Four check boxes | all ticked | Left, Right, Top, Bottom. A frame on three sides is normal on a sheet where the fourth carries the legend. |
Labels tab
| ផ្ទាំងគ្រប់គ្រង | ប្រភេទ | តម្លៃលំនាំដើម | ការពិពណ៌នា |
|---|---|---|---|
| Show coordinate labels | Group check box | On | Off leaves the lines and the frame with no numbers. |
| Number format | Combo box | Decimal | Decimal, Decimal with N/S/E/W, degree/minute and degree/minute/second variants, plus four that label from an expression: MGRS zone and band letter, MGRS 100 km square letter, MGRS principal digits, MGRS corner value, and Custom expression. |
| UTM zone | Integer (0–60) | from the coordinate system | MGRS 100 km square letter only. At 0 it is read from the grid's own CRS, which is what the MGRS preset sets. |
| Expression | Text | — | Custom expression only. A QGIS expression, with @grid_number for the value of the line being labelled and @grid_axis for 'x' or 'y'. |
| Label rule | Read-only text | — | Shown for the four expression formats: exactly what will be written onto the grid. Change the interval and watch the divisor change with it. |
| Decimals | Integer (0–12) | 0 | Hidden for the four expression formats — QGIS does not consult it under a custom format, so leaving it on screen would be a control that does nothing. |
| Distance from the frame | Number | 1 mm | |
| Font / Label colour | Font button, colour button | QGIS default, black | Family, size and style. |
| Each side | Four rows | Show all, outside, horizontal | One row per side with Show, Placement (outside or inside the frame) and Orientation. Copy the Left row to every side does the common case in one press. |
របៀបប្រើ
The tool needs a print layout with a map item on it. Run it without one and it says so and stops.
- Open the layout in Project > Layouts, and click the map item to select it.
- Back in the main window, run KGA Mapping > Add Grid to Layout. The window opens on that layout and that map, in front of the layout designer rather than behind it, so the form and the sheet are on screen together.
- Pick a Preset if one is close to what you want.
- Press Suggest to get a round interval for the scale the map is at.
- Set the frame and the label sides, then press Add Grid.
- Look at the sheet, change a number, press Apply again. Repeat until it reads right at print size.
The MGRS preset
A grid reference such as 48P VT 92 77 is four things: the zone number, the latitude band letter, the 100 km square letters and the numeric location. They are read off different grids, so the preset lays down four, plus up to three more you can tick on.
| Grid | What it draws | What it labels |
|---|---|---|
MGRS zone 48P | A 6° × 8° graticule in EPSG:4326 | The zone number along the top and bottom, the band letter up the sides — inside the frame |
MGRS 100 km squares | A 100,000 m grid in the map's UTM zone | The square's column letter on the vertical lines, its row letter on the horizontal ones |
MGRS corner values | Nothing — no lines, no frame | One label per margin: the first line's coordinate written out in full. It follows the map — pan or zoom and it re-finds the first line by itself |
MGRS 1 km mesh (optional) | A 1 km grid, lighter than the one above it | Nothing — see the notes |
MGRS interior northing/easting labels (optional) | Nothing | The same principal digits repeated against the inside of the frame |
MGRS 1 km (or 10 km, 100 m…) | The fine grid | The principal digits, never fewer than two, with the 100 km digits raised and small on every tenth line: 78 79 ⁴⁸⁰ 81 |
- Select the map and run the tool as above.
- Pick MGRS grid from the bottom of the Preset list. Nothing is written yet: the button changes to Add MGRS Grid (4 grids) and its count follows what you tick.
- Set the font, colours and frame if you want them different — everything the set does not fix for itself is taken from the form when you press Add.
- Choose whether the 100 km letters go in the margin or inside the map. Inside keeps the margin to the numbers alone, which is how a printed sheet does it.
- Set the Grid interval if
Automaticis not what the sheet needs. Tick 1 km mesh and Labels inside too if you want them. - Press Add MGRS Grid. One undo step; the tool is left editing the fine grid, and the others are in the Grid list.
លទ្ធផល
- A grid on the chosen map item of the chosen print layout. Nothing is written to disk; the grid is part of the layout and is saved with the project.
- Adding, changing and removing are each one undo step in the layout designer, so Ctrl+Z there takes back exactly one press of Apply.
កំណត់សម្គាល់ និងដែនកំណត់
- It checks there is something to grid before it opens. A project with no layout — or with layouts carrying no map item — gets a message saying which of the two is missing, and nothing opens.
- MGRS is written in this plugin, because QGIS has none. There is no MGRS in the QGIS C++ or Python API. The maths is WGS84 only, no UPS, and is checked against PROJ and against the standard
4QFJ 12345 67890example. - The GZD graticule draws nothing on most sheets. Its lines are 6° apart across and 8° up, so on any map smaller than a zone cell there is no line to draw. On a single-zone sheet, put
48Pin a layout label instead. - Above 84° N and below 80° S there is no MGRS grid. Those latitudes use UPS, which the tool does not draw. The preset refuses and says so.
- One sheet, one zone. All the grids use the zone at the middle of the map. A map crossing a zone boundary is gridded anyway and warned about. That is a property of MGRS, not of this tool.
- The labels are an expression, so they survive without the plugin. They are written as QGIS's own Custom annotation format with self-contained expression text. The cost is that QGIS's Decimals setting stops applying, which is why that row is hidden for these formats.
- The margin never prints a single digit. The labels are floored at two, which is the convention on a 1:50,000 sheet — a margin of bare single digits reads as a ruler rather than as coordinates.
- The raised 100 km digits are Unicode superscripts. QGIS gives a grid one font per label, so there is no way to set part of it smaller. Nearly every font has these glyphs, but one that does not will draw boxes.
- The 1 km mesh carries no numbers. A second row of labels would land in the same margin row and overlap it. The mesh is there to measure against, not to name.
- Interior labels are a grid of their own. QGIS gives one grid a single label position per side, so repeating the numbers inside the frame needs a second grid rather than a second setting.
- The interval is in the grid's CRS, not the map's. Switching to EPSG:4326 with an interval of 1000 left over from a metre grid means 1000 degrees, and draws nothing. The tool re-suggests the interval whenever the CRS changes.
- Fit the page automatically cannot carry MGRS digits. QGIS recomputes that interval at every render and the expression cannot follow it, so the combination is refused.
- Labels outside the frame draw beyond the map item's rectangle. They can overrun a neighbouring item or the edge of the page; the map item does not grow to make room.
- The window follows the layout it is working on, and closing that designer closes this window with it. Nothing is lost — the grid is already on the map; re-run the tool and pick it under Grid.
- Only print layouts are offered. A report is not a layout the tool can put a grid on.