arma3:terrain:qgis-real-world-data-tutorial
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
arma3:terrain:qgis-real-world-data-tutorial [2019/01/17 08:33] – snakeman | arma3:terrain:qgis-real-world-data-tutorial [2024/08/02 18:53] (current) – links added. snakeman | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== QGIS Real World Data Tutorial ====== | + | ====== |
- | ArmA 3 QGIS Real World Data Tutorial By Ross | + | [[https:// |
- | This process has often been described using Global Mapper, but I wanted to detail the equivalent steps within the open source GIS app QGIS. | + | **ArmA 3 QGIS Real World Data Tutorial** by Ross |
- | The goal is to achieve an export satellite image and heightmap with the same or better quality than would be possible with Global Mapper. | + | This process has often been described using Global Mapper, but I wanted to detail the equivalent steps within the open source (free) GIS app - QGIS. |
- | The is my second revision of this process as I recently discovered that due to an update to GDAL (**2.4.0**) one of the key steps in the original tutorial using ' | + | The goal was to achieve |
- | So I reworked the process by getting a bit more under the hood, and using GDAL command | + | I've used GDAL command |
- | Using following versions: | + | The following |
**[[https:// | **[[https:// | ||
**[[https:// | **[[https:// | ||
+ | |||
+ | I have referenced Terra Incognita because i felt it was the easiest way to obtain satellite data in the oziexplorer map format - see this **[[https:// | ||
**First an overview of the steps required:** | **First an overview of the steps required:** | ||
Line 21: | Line 23: | ||
==== For Heightmap: ==== | ==== For Heightmap: ==== | ||
- | * Load heightmap into | + | * Load heightmap into QGIS (drag and drop) |
* Set QGIS to appropriate CRS for location of your HM | * Set QGIS to appropriate CRS for location of your HM | ||
- | * Create shapefile & generate square | + | * Create shapefile & generate |
* Obtain extents from square feature | * Obtain extents from square feature | ||
* Run 2 GDAL commands | * Run 2 GDAL commands | ||
- | * First to set cell size, CRS and then clip to shapefile | + | * First to set cell size, CRS and then clip to shapefile |
* Second to convert to .asc file | * Second to convert to .asc file | ||
Line 34: | Line 36: | ||
**For single tile export** | **For single tile export** | ||
- | * Load in just the .map files into QGIS | + | * Load in just the '.map' |
- | * Merge Rasters | + | * Merge rasters |
* Obtain extents from square feature | * Obtain extents from square feature | ||
- | * gdalwarp command will set cell size, CRS and then clip to shapefile | + | * gdalwarp command will set cell size, CRS and then clip to shapefile |
- | **For 4 tile export** | + | **For 4 tile export |
- | * Load in just the .map files into QGIS | + | * Load in just the '.map' |
* Merge Rasters | * Merge Rasters | ||
* Create grid -- 2 x 2 Feature | * Create grid -- 2 x 2 Feature | ||
* Move each quarter to its own shapefile layer | * Move each quarter to its own shapefile layer | ||
* Obtain extents from each quarter feature | * Obtain extents from each quarter feature | ||
- | * Run gdalwarp command for each quarter to set cell size and CRS and clip to shapefile square | + | * Run gdalwarp command for each quarter to set cell size and CRS and clip to shapefile square extents |
**And now detailed steps for:** | **And now detailed steps for:** | ||
Line 52: | Line 54: | ||
===== Heightmap: ===== | ===== Heightmap: ===== | ||
+ | |||
+ | This tutorial covers single raster heightmap as per the kind you will find on [[https:// | ||
**Drag and drop your heightmap ' | **Drag and drop your heightmap ' | ||
+ | |||
+ | If you do use opentopo for source of Heightmap, make sure extract both the **.asc** and **.prj** files before proceeding with below. They should both be in the zip file from opentopo. | ||
**Set QGIS to appropriate CRS for location of your HM** | **Set QGIS to appropriate CRS for location of your HM** | ||
Line 61: | Line 67: | ||
{{https:// | {{https:// | ||
- | Select the CRS to match your real world data, in this example its ‘**WGS 84 UTM zone 20N**’ because the terrain is from the Montserrat in the Caribbean. See also [[https:// | + | Select the CRS to match your real world data, in this example its ‘**WGS 84 UTM zone 20N**’ because the terrain is from the Montserrat in the Caribbean. See also [[https:// |
- | + | This will ensure your QGIS project space works appropriately with any other data you want to add - eg road shapefiles etc. Terrain Builder will only use **UTM 31N** but we'll get to that later. | |
- | This will ensure your QGIS project space works appropriately with any other data you want to add - eg road shapefiles etc. Terrain Builder will only use UTM 31N but we'll get to that later. | + | |
{{https:// | {{https:// | ||
Line 69: | Line 74: | ||
**Create shapefile & generate square feature using Advanced Digitizing panel** | **Create shapefile & generate square feature using Advanced Digitizing panel** | ||
- | Top menu -- **Layer **> | + | Top menu -- **Layer **> **Create Layer** > **New Shapefile Layer** |
Save to project folder location | Save to project folder location | ||
Line 83: | Line 88: | ||
{{https:// | {{https:// | ||
- | From menu -- **View** → **Toolbars** → **Advanced Digitizing Toolbar** | + | From menu -- **View** → **Toolbars** → **Advanced Digitizing Toolbar** |
{{https:// | {{https:// | ||
Line 95: | Line 100: | ||
{{https:// | {{https:// | ||
- | To create a perfect square, | + | To create a perfect square, **left mouse click** for your **top left** starting point, move your mouse to the right a little, then press ‘**d**’ on keyboard, type in the exact width (distance) required (in this example ‘20480’) then immediately |
{{https:// | {{https:// | ||
- | See a short video example using the **Advanced Digitizing** tool: | + | See a short video example using the **Advanced Digitizing** tool: |
{{https:// | {{https:// | ||
- | After the last **left mouse click** from the step above, the tool is still waiting to plot more points, so to finalise | + | After the last **left mouse click** from the step above, the tool is still waiting to plot more points, so to finalize |
{{https:// | {{https:// | ||
- | This will then bring up a dialogue -- just type any number and Enter | + | This will then bring up an attributes |
{{https:// | {{https:// | ||
+ | |||
+ | Save the above edits to the shapefile by clicking on the layer & selecting ‘**Toggle Editing**’ | ||
**Obtain extents from square feature** | **Obtain extents from square feature** | ||
Line 119: | Line 126: | ||
Start typing ' | Start typing ' | ||
- | Double click it and make sure your square **input layer** is selected - then just click **Run** | + | Double click it and make sure your square |
{{https:// | {{https:// | ||
- | You will only need to copy the **Extent** figures, | + | You will only need to copy the **Extent** figures, which we will use within the GDAL commands in the next step |
{{https:// | {{https:// | ||
- | **Run the first GDAL command | + | **Run the first GDAL command |
- | From menu - **Plugins** > | + | From menu - **Plugins** > **Python Console** |
Click ' | Click ' | ||
Line 135: | Line 142: | ||
{{https:// | {{https:// | ||
- | The blank window on the right is where you will enter GDAL commands | + | The blank window on the right is where you will paste GDAL commands |
Now you are ready to edit the command below to match your data - sections in bold are the parts to edit: | Now you are ready to edit the command below to match your data - sections in bold are the parts to edit: | ||
import os\\ | import os\\ | ||
- | os.system(r%%''' | + | os.system(r%%''' |
Some explanation of the key parameters: | Some explanation of the key parameters: | ||
- | **-t_srs EPSG:32620 **\\ | + | **-t_srs EPSG:32620 **\\ |
CRS to match where the heightmap is from in the world. | CRS to match where the heightmap is from in the world. | ||
**-tr 5.0 5.0**\\ | **-tr 5.0 5.0**\\ | ||
- | The desired resolution of your heightmap, match with Cell size set within your Mapframe properties in Terrain Builder: | + | The desired resolution of your heightmap, match with **Cell size** set within your Mapframe properties in Terrain Builder: |
{{https:// | {{https:// | ||
**-te 576787.687480 1841104.815839 597267.687480 1861584.815839**\\ | **-te 576787.687480 1841104.815839 597267.687480 1861584.815839**\\ | ||
- | The 4 long figures represent | + | The 4 long figures represent |
Update the paths to match where you are storing your source heightmap, and where you want the output tif saved to. | Update the paths to match where you are storing your source heightmap, and where you want the output tif saved to. | ||
Input:\\ | Input:\\ | ||
- | **D:/ | + | **D:/ |
Output:\\ | Output:\\ | ||
Line 164: | Line 171: | ||
**Run second GDAL command - converting tif from above step to a Terrain Builder friendly .asc** | **Run second GDAL command - converting tif from above step to a Terrain Builder friendly .asc** | ||
+ | |||
+ | Remember to change the paths in below command to match where your files are located | ||
import os\\ | import os\\ | ||
- | os.system(r%%''' | + | os.system(r%%''' |
Line 173: | Line 182: | ||
==== For single tile export ==== | ==== For single tile export ==== | ||
- | **Load in just the .map files into QGIS** | + | **Load in just the '.map' |
{{https:// | {{https:// | ||
Line 179: | Line 188: | ||
**Merge Rasters** | **Merge Rasters** | ||
- | Top Menu -** Raster **→ **Miscellaneous **→ **Merge** | + | Top Menu -** Raster |
Select all your .map files as input layers | Select all your .map files as input layers | ||
Line 185: | Line 194: | ||
{{https:// | {{https:// | ||
- | change **Output data type** to ‘Byte’ as the default is ‘Float32’. | + | change |
Select ‘**Save to File**’ under Merged -- as the default is to a temporary file. | Select ‘**Save to File**’ under Merged -- as the default is to a temporary file. | ||
Line 193: | Line 202: | ||
**Obtain extents from square feature** | **Obtain extents from square feature** | ||
- | You should already have this from working on heightmap | + | You should already have this from working on heightmap |
**Run GDAL command** | **Run GDAL command** | ||
import os\\ | import os\\ | ||
- | os.system(r%%''' | + | os.system(r%%''' |
Some explanation of the key parameters: | Some explanation of the key parameters: | ||
Line 224: | Line 233: | ||
**Create grid -- 2 x 2 Feature** | **Create grid -- 2 x 2 Feature** | ||
- | You will need to have created | + | You will need to have created |
- | Top Menu -- **View** → **Panels** → **Processing Toolbox** | + | Top Menu -- **View** → **Panels** → **Processing Toolbox** |
- | Processing Toolbox Menu -- **Vector Creation** > | + | Processing Toolbox Menu -- **Vector Creation** > **Create Grid** |
- | Set **Grid type** to ‘**Rectangle (polygon)**’ & the **Horizontal & Vertical** to half the distance of your main square | + | Set **Grid type** to ‘**Rectangle (polygon)**’ & the **Horizontal & Vertical** to half the distance of your main square |
Set it to save new grid feature to .shp file | Set it to save new grid feature to .shp file | ||
Line 236: | Line 245: | ||
{{https:// | {{https:// | ||
- | Select the shapefile layer for your square | + | After clicking '**Use Layer Extent**' |
{{https:// | {{https:// | ||
- | After clicking **Run**, your original square will then be Covered with a new grid of 4 tiles -- perfect quarters of your original square | + | After clicking |
{{https:// | {{https:// | ||
Line 248: | Line 257: | ||
Because you will need to export each quarter separately for use in Terrain Builder, we will move each quarter onto its own shapefile layer. | Because you will need to export each quarter separately for use in Terrain Builder, we will move each quarter onto its own shapefile layer. | ||
- | Click **Select Features** - | + | Click **Select Features** - |
{{https:// | {{https:// | ||
Line 256: | Line 265: | ||
{{https:// | {{https:// | ||
- | Top Menu -- **Edit** > | + | Top Menu -- **Edit** > **Copy Features** |
- | Then… **Edit** → **Paste Features | + | Then… **Edit** → **Paste Features |
Save shapefile layer to something obvious | Save shapefile layer to something obvious | ||
Line 284: | Line 293: | ||
And list them out for safe keeping - | And list them out for safe keeping - | ||
- | TL - Extent: (576787.687480, | + | **TL - Extent**: (576787.687480, |
- | TR - Extent: (587027.687480, | + | **TR - Extent**: (587027.687480, |
- | BL - Extent: (576787.687480, | + | **BL - Extent**: (576787.687480, |
- | BR - Extent: (587027.687480, | + | **BR - Extent**: (587027.687480, |
**Run GDAL command for each quarter to set cell size and CRS and clip to shapefile square extents** | **Run GDAL command for each quarter to set cell size and CRS and clip to shapefile square extents** | ||
Line 297: | Line 306: | ||
===== Loading your assets into Terrain Builder ===== | ===== Loading your assets into Terrain Builder ===== | ||
+ | I would recommend saving copies of any files to be used in **Terrain Builder** into a separate terrain project folder. This will prevent your source project files being adversely affected, and potentially no longer working within **QGIS** - particularly relevant to those changes mentioned below. | ||
**Heightmap (.asc) edits** | **Heightmap (.asc) edits** | ||
- | Open your asc and change the following: | + | Open your **asc** in notepad |
{{https:// | {{https:// | ||
- | Before loading the asc file into Terrain Builder, delete the .prj file. Otherwise it will not import into TB. | + | Save to a new asc, whilst maintaining the original for use in your QGIS project space |
+ | |||
+ | Before loading the asc file into **Terrain Builder**, delete the .prj file. Otherwise it will not import into TB. | ||
{{https:// | {{https:// | ||
Line 311: | Line 323: | ||
- | Before loading the satellite image into Terrrain | + | Before loading the satellite image into Terrain |
{{https:// | {{https:// | ||
Line 327: | Line 339: | ||
{{https:// | {{https:// | ||
- | **Coming Soon:** | + | ===== Preparing Road Shapefile ===== |
- | * Road shapefile | + | |
- | * Assisted image classification | + | **Load into QGIS (drag and drop) road shapefile** |
- | * 3d preview | + | |
+ | In this example I got a good dataset from - [[https:// | ||
+ | |||
+ | {{https:// | ||
+ | |||
+ | **Clip vector to square shape** | ||
+ | Top Menu - **Vector** > **Geoprocessing Tools** > **Clip** | ||
+ | |||
+ | {{https:// | ||
+ | |||
+ | Save features from clip to new shapefile - selecting appropriate CRS, in this example | ||
+ | |||
+ | Top Menu - **Layer** > **Save As** | ||
+ | |||
+ | {{https:// | ||
+ | |||
+ | **Set road shapefile | ||
+ | |||
+ | RMB on road shapefile > **Set CRS** > **Set Layer CRS** | ||
+ | |||
+ | {{https:// | ||
+ | |||
+ | {{https:// | ||
+ | |||
+ | **Set QGIS project CRS to UTM- 31N (bottom right corner): | ||
+ | |||
+ | {{https:// | ||
+ | |||
+ | **Collect extents from your square shapefile: | ||
+ | |||
+ | {{https:// | ||
+ | |||
+ | Extent: (**576787.687480**, | ||
+ | |||
+ | The first two values will be used in the v.transform step below. | ||
+ | |||
+ | |||
+ | **v.transform on road shapefile using calculated extents from square shapefile** | ||
+ | |||
+ | Your heightmap asc must adhere to Terrain Builders required values | ||
+ | Your road shapefile also needs to line up to the same values - we will use **v.transform** to achieve this | ||
+ | |||
+ | So taking the extent values we grabbed in previous step -\\ | ||
+ | We will do the following calculations to bring these values to (**200000** and **0**):\\ | ||
+ | **Easting: | ||
+ | **Northing: 1841104.815839 - 1841104.815839 = 0**\\ | ||
+ | |||
+ | **-376787.68748**\\ | ||
+ | **-1841104.815839** | ||
+ | |||
+ | |||
+ | Having figured out the correct figures plug them into the **v.transform** process | ||
+ | |||
+ | {{https:// | ||
+ | |||
+ | Drag and Drop into QGIS your heightmap asc - the one you are able to load into Terrain builder - already adjusted to (**200000**, | ||
+ | |||
+ | Set CRS on above asc to **UTM - 31N** | ||
+ | |||
+ | Right click on asc in **Layers** > **Zoom to Layer** | ||
+ | |||
+ | In **Layers** panel drag the asc below your **transformed road shapefile** - so you can see the roads layered above the asc | ||
+ | |||
+ | {{https:// | ||
+ | |||
+ | Your roads should now be perfectly aligned above your heightmap | ||
+ | |||
+ | {{https:// | ||
+ | |||
+ | ==== Setting ID and ORDER fields ==== | ||
+ | |||
+ | RMB on transformed shapefile layer > Toggle **Editing** | ||
+ | |||
+ | RMB on transformed shapefile layer > Open **Attribute Table** | ||
+ | |||
+ | |||
+ | Click **Delete field** - select all fields and press **OK** | ||
+ | |||
+ | {{https:// | ||
+ | |||
+ | New Field - Name ' | ||
+ | |||
+ | {{https:// | ||
+ | |||
+ | New Field - Name ' | ||
+ | |||
+ | {{https:// | ||
+ | |||
+ | Toggle - **Multi Edit mode** | ||
+ | |||
+ | {{https:// | ||
+ | |||
+ | ID - Enter **0** - click **Update All** | ||
+ | |||
+ | {{https:// | ||
+ | |||
+ | Select ORDER from drop down - Enter **1** - click **Update all** | ||
+ | |||
+ | {{https:// | ||
+ | |||
+ | Click - **Switch to table view** | ||
+ | |||
+ | {{https:// | ||
+ | |||
+ | Click **Save** | ||
+ | |||
+ | {{https:// | ||
+ | |||
+ | RMB on transformed road shapefile - **Toggle Editing** to save the changes | ||
+ | |||
+ | |||
+ | **Switching to Terrain Builder -** | ||
+ | |||
+ | |||
+ | **Load your road shapefile** | ||
+ | |||
+ | Top menu - **File** > **Import** > **Shapes** | ||
+ | |||
+ | Click **OK** | ||
+ | |||
+ | {{https:// | ||
+ | |||
+ | Perfectly overlaid within **Terrain builder: | ||
+ | |||
+ | {{https:// | ||
+ | |||
+ | ===== 3D Preview using Qgis2threejs ===== | ||
+ | |||
+ | If you want to see an instant | ||
+ | |||
+ | First install it: | ||
+ | |||
+ | Top menu > **Plugins** > **Manage and Install Plugins** | ||
+ | |||
+ | {{https:// | ||
+ | |||
+ | RMB on the Merged layer and select **Zoom to Layer** | ||
+ | |||
+ | Then select both the **Merged** raster, and the original source heightmap - deselect all other layers | ||
+ | |||
+ | {{https:// | ||
+ | |||
+ | Start the Qgis2threejs plugin - Top Menu > **Web** > **Qgis2threejs** > **Qgis2threejs Exporter** | ||
+ | |||
+ | {{https:// | ||
+ | |||
+ | Select source heightmap and nothing else | ||
+ | |||
+ | RMB on heightmap > **Properties** | ||
+ | |||
+ | Set the **Resampling** level to **6** | ||
+ | |||
+ | Set **Resolution** to **400%** | ||
+ | |||
+ | {{https:// | ||
+ | |||
+ | Enjoy browsing around your terrain in 3D: | ||
+ | |||
+ | {{https:// | ||
+ | |||
+ | You can also export your terrain to a browser interface if you want - **File** > **Export to web** |
arma3/terrain/qgis-real-world-data-tutorial.1547714018.txt.gz · Last modified: 2019/01/17 08:33 by snakeman