Skip to content

Commit 1977ac8

Browse files
committed
ex3
1 parent 19af03c commit 1977ac8

File tree

5 files changed

+64
-7
lines changed

5 files changed

+64
-7
lines changed

exercise1.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ Once we're satisfied with the output, we are ready to save it as a GeoJSON file.
6666

6767
13. Right-click the "Refactored" layer > Make Permanent...
6868
- Set Format = GeoJSON
69-
- Always click the '...' button to specify where you want the file saved!
69+
- Always click the `...` button to specify where you want the file saved!
7070
- Under Layer Options, set RFC7946 = YES (this will force it into WGS84, and set decimal precision at 7 digits)
7171

7272
Now you should have an index map saved as a GeoJSON file! If you open it in a text editor, you'll see that it starts something like this:

exercise2.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,11 @@ Use the "Refactor fields" tool to rename or delete several of the fields:
4545
- Always click the `...` button to specify where you want the file saved!
4646
- Under Layer Options, set RFC7946 = YES (this will force it into WGS84, and set decimal precision at 7 digits)
4747

48-
Now we have all the points saved to a single GeoJSON file. What if we wanted to save each county separately, based on the "county" column?
48+
Now we have all the points saved to a single GeoJSON file.
49+
50+
## 6. Save a GeoJSON for each county
51+
52+
What if we wanted to save each county separately, based on the "county" column?
4953

5054
- Open the "Split Vector Layer" tool
5155
- Input layer = "Points from table"

exercise3.md

Lines changed: 58 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,60 @@
11
# Exercise 3: Create a grid index map from scratch
2-
- Create grid in QGIS
3-
- formula for grid labels
4-
- label expression like `char(45-bottom+65)||(left+81)`
5-
- once the formula looks good, calculate new 'label' column using the expression
6-
- edit form for names - can hide columns (layer properties > attributes form > drag and drop designer)
72

3+
In this scenario, we will create an index map from scratch, using a grid of 15-minute quads for the state of Colorado. We'll use the Stamen Toner basemap for reference, because the state boundaries are easier to see.
4+
5+
- Start a new project in QGIS and add the Stamen Toner basemap
6+
7+
## 1. Create the grid
8+
9+
A 15-minute quad is 15/60 or 1/4 of a degree, so we need to create a rectangular grid where each cell is 0.25 degrees wide and tall. To cover all of Colorado, so we'll need to figure out the lat/lon bounds of the state.
10+
11+
- Zoom in to Colorado (shift-drag will zoom into the rectangle you select)
12+
- Click the Project CRS ![EPSG:3857](https://kgjenkins.github.io/openindexmaps-workshop/image/project-crs.png) and change it to EPSG:4326 "WGS 84"
13+
- Open the "Create Grid" processing tool
14+
- Grid type = Rectangle (Polygon)
15+
- Grid extent -- click `...` > Select extent on canvas, then drag a rectangle covering Colorado
16+
- Fine tune the coordinates by rounding to the nearest whole number ("-109, -102, 37, 41")
17+
- Set the horizontal and vertical spacing to 0.25 degrees
18+
- Click "Run"
19+
20+
## 2. Label the cells
21+
22+
Let's suppose we have a Colorado map series that uses these quads, and each map is number A1, A2, A3 across the top row, and A1, B1, C1 down the left column, like this:
23+
24+
![grid labels](https://kgjenkins.github.io/openindexmaps-workshop/image/ex3-grid-labels.png)
25+
26+
Although we could just add a new column and type in the value for every cell, that would be very tedious and prone to error. With some experimentation, we can figure out a formula for calculating the code for each cell.
27+
28+
Use the Identify tool ![identify tool](https://kgjenkins.github.io/openindexmaps-workshop/image/identify-tool.png) to look at the attributes for one of the grid cells. Notice that it includes values for the left, top, right, and bottom coordinates of the cell.
29+
30+
- Open the Layer Styling Panel, and select the "Grid" layer
31+
- Click the "ABC" button on the left of the panel to switch to label styling
32+
- Change "No labels" to "Single labels"
33+
- Set Value = `top`
34+
35+
QGIS dynamic label expressions can help us to figure out the formula in an iterative manner. The complete formula is below, but here is the sequence used to figure it out. After typing to change the `top` expression, just press "tab" or click elsewhere and the labels will update on the map.
36+
37+
- `top*4` (to get whole numbers)
38+
- `165-top*4` (so that the top row is 1, and the numbers increase southwards)
39+
- `char(64 + 165-top*4)` (this converts the numbers to letters -- char(65) is A, char(66) is B, etc.)
40+
- `char(64 + 165-top*4) || (left*4)` (this appends numbers based on the longitude)
41+
- `char(64 + 165-top*4) || (437 + left*4)` (so that the left column is 1, and increases to the east)
42+
43+
Once the expression is generating the correct codes, we can copy it and use it to create a new column.
44+
45+
- Copy the value expression for the labels
46+
- Open the Field Calculator ![field calculator button](https://kgjenkins.github.io/openindexmaps-workshop/image/field-calculator.png)
47+
- Output field name = "code"
48+
- Output field type = "Text (string)"
49+
- Paste the expression into the large area on the left of the dialog
50+
- Check the output preview beneath
51+
- Click "OK" -- the adds the column, but now we are in edit mode
52+
- Click the pencil icon to toggle editing off (save when prompted)
53+
54+
Now the code is just another property that could be used when we run "Refactor Fields".
55+
56+
When in edit mode, other fields could be added and edited while viewing the attribute table.
57+
58+
----
59+
60+
Next: [Exercise 4](exercise4)

image/ex3-grid-labels.png

21.8 KB
Loading

image/field-calculator.png

596 Bytes
Loading

0 commit comments

Comments
 (0)