User Tools

Site Tools


arma3:terrain:qgis-real-world-data-tutorial

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision Both sides next revision
arma3:terrain:qgis-real-world-data-tutorial [2019-01-17 08:33]
snakeman
arma3:terrain:qgis-real-world-data-tutorial [2019-01-20 10:01]
snakeman fixed typos.
Line 3: Line 3:
 ArmA 3 QGIS Real World Data Tutorial By Ross ArmA 3 QGIS Real World Data Tutorial By Ross
  
-This process has often been described using Global Mapper, but I wanted to detail the equivalent steps within the open source GIS app QGIS.+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 goal is to achieve an export satellite image and heightmap with the same or better quality than would be possible with Global Mapper.+The goal was to achieve an export satellite image and heightmap with the same or better quality than would be possible with Global Mapper.
  
-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 '​**Clip Raster by Mask Layer**'​ no longer works perfectly!+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 '​**Clip Raster by Mask Layer**'​ no longer works perfectly!
  
-So I reworked the process by getting a bit more under the hood, and using GDAL command line where possible, this also simplifies the process a little and reduced even further ​processing on ​the data.+So I reworked the process by getting a bit more under the hood, and using GDAL command line where possible, this also simplifies the process a little and reduced even further ​processing on the data.
  
-Using following ​versions:+This tutorial used the following ​software:
  
 **[[https://​qgis.org/​en/​site/​forusers/​download.html|QGIS v3.4.3]]** **[[https://​qgis.org/​en/​site/​forusers/​download.html|QGIS v3.4.3]]**
  
 **[[https://​sourceforge.net/​projects/​terraincognita2/​files/​|Terra Incognita v2.45]]** **[[https://​sourceforge.net/​projects/​terraincognita2/​files/​|Terra Incognita v2.45]]**
 +
 +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://​pmc.editing.wiki/​doku.php?​id=arma3:​terrain:​satellite-texture-terra-incognita|tutorial]]** for help using Terra Incognita.
  
 **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 ​QGIS (drag and drop)+  * 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 ​feature ​using Advanced Digitizing panel+  * Create shapefile & generate ​perfect ​square using Advanced Digitizing panel
   * 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 ​square extents+    * First to set cell size, CRS and then clip to shapefile ​square extents
     * 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' ​files generated in Terra Incognita ​into QGIS 
-  * 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 ​square extents+  * gdalwarp command will set cell size, CRS and then clip to shapefile ​square extents
  
-**For 4 tile export**+**For 4 tile export ​(large projects 40960 and above)**
  
-  * Load in just the .map files into QGIS+  * Load in just the '.map' ​files generated in Terra Incognita ​into QGIS
   * 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 ​feature ​extents+  * 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 54: Line 56:
  
 **Drag and drop your heightmap '​.asc'​ into QGIS** **Drag and drop your heightmap '​.asc'​ into QGIS**
 +
 +This tutorial covers single raster heightmap as per the kind you will find on opentopo [[http://​opentopo.sdsc.edu/​raster?​opentopoID=OTSRTM.082015.4326.1|here]],​ I will detail steps for heightmaps spread across muliptle rasters in another update. as they will require additional steps likely including Merge / Build Virtual Raster commands.
  
 **Set QGIS to appropriate CRS for location of your HM** **Set QGIS to appropriate CRS for location of your HM**
Line 61: Line 65:
 {{https://​pmc.editing.wiki/​images/​Ross-QGIS-Tutorial-11b.png}} {{https://​pmc.editing.wiki/​images/​Ross-QGIS-Tutorial-11b.png}}
  
-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://​pmc.editing.wiki/​doku.php?​id=arma3:​terrain:​utm-projection|UTM projection]]. +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://​pmc.editing.wiki/​doku.php?​id=arma3:​terrain:​utm-projection|UTM projection]].\\
 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.
  
Line 69: Line 72:
 **Create shapefile & generate square feature using Advanced Digitizing panel** **Create shapefile & generate square feature using Advanced Digitizing panel**
  
-Top menu -- **Layer **>​ **Create Layer** >​ **New Shapefile Layer**+Top menu -- **Layer **> **Create Layer** > **New Shapefile Layer**
  
 Save to project folder location Save to project folder location
Line 83: Line 86:
 {{https://​pmc.editing.wiki/​images/​Ross-QGIS-Tutorial-15b.png}} {{https://​pmc.editing.wiki/​images/​Ross-QGIS-Tutorial-15b.png}}
  
-From menu -- **View** → **Toolbars** → **Advanced Digitizing Toolbar**+From menu -- **View** → **Toolbars** → **Advanced Digitizing Toolbar**
  
 {{https://​pmc.editing.wiki/​images/​Ross-QGIS-Tutorial-16.png}} {{https://​pmc.editing.wiki/​images/​Ross-QGIS-Tutorial-16.png}}
Line 95: Line 98:
 {{https://​pmc.editing.wiki/​images/​Ross-QGIS-Tutorial-18.png}} {{https://​pmc.editing.wiki/​images/​Ross-QGIS-Tutorial-18.png}}
  
-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 ​press **Enter** -- be careful not to move the mouse before ​pressing **Enter** or it will mess up the number. ​Press **left mouse click** and you will have drawn your first horizontal line which turns red. By default this tool snaps to 90 degree angles, making it easy to draw your lines. Now to draw the vertical line start moving mouse your down, press ‘d’ again and type in same figure as above, ​press **Enter** and ​another **left mouse click**, repeat the process for the last 2 lines of the 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 ​press **Enter** -- be careful not to move the mouse before ​pressing ​**Enter** or it will mess up the number. ​Press **left mouse click** and you will have drawn your first horizontal line which turns red. By default this tool snaps to 90 degree angles, making it easy to draw your lines. Now to draw the vertical line start moving mouse your down, press ‘d’ again and type in same figure as above, ​press **Enter** and another ​**left mouse click**, repeat the process for the last 2 lines of the square.
  
 {{https://​pmc.editing.wiki/​images/​Ross-QGIS-Tutorial-19b.png}} {{https://​pmc.editing.wiki/​images/​Ross-QGIS-Tutorial-19b.png}}
  
-See a short video example using the **Advanced Digitizing** tool:​+See a short video example using the **Advanced Digitizing** tool:
  
 {{https://​pmc.editing.wiki/​images/​Ross-QGIS-Tutorial-AdvancedDigitizing.gif}} {{https://​pmc.editing.wiki/​images/​Ross-QGIS-Tutorial-AdvancedDigitizing.gif}}
  
-After the last **left mouse click** from the step above, the tool is still waiting to plot more points, so to finalise the square do **right mouse click**+After the last **left mouse click** from the step above, the tool is still waiting to plot more points, so to finalise the square do **right mouse click**
  
 {{https://​pmc.editing.wiki/​images/​Ross-QGIS-Tutorial-20b.png}} {{https://​pmc.editing.wiki/​images/​Ross-QGIS-Tutorial-20b.png}}
  
-This will then bring up dialogue -- just type any number and Enter+This will then bring up an attributes ​dialogue -- just type any number and Enter
  
 {{https://​pmc.editing.wiki/​images/​Ross-QGIS-Tutorial-21.png}} {{https://​pmc.editing.wiki/​images/​Ross-QGIS-Tutorial-21.png}}
Line 119: Line 122:
 Start typing '​**vector**'​ in Processing Toolbox search bar, and you will see '​**Vector information**'​ Start typing '​**vector**'​ in Processing Toolbox search bar, and you will see '​**Vector information**'​
  
-Double click it and make sure your square **input layer** is selected - then just click **Run**+Double click it and make sure your square ​**input layer** is selected - then just click **Run**
  
 {{https://​pmc.editing.wiki/​images/​Ross-QGIS-Tutorial-01.png}} {{https://​pmc.editing.wiki/​images/​Ross-QGIS-Tutorial-01.png}}
  
-You will only need to copy the **Extent** figures,​ which we will use within the GDAL commands in the next step+You will only need to copy the **Extent** figures, which we will use within the GDAL commands in the next step
  
 {{https://​pmc.editing.wiki/​images/​Ross-QGIS-Tutorial-02.png}} {{https://​pmc.editing.wiki/​images/​Ross-QGIS-Tutorial-02.png}}
  
-**Run the first GDAL command ​to set CRS, cell size and then clip to shapefile square extents**+**Run the first GDAL command ​which will - set CRS, cell size and then clip to shapefile square extents**
  
-From menu - **Plugins** >​ **Python Console**+From menu - **Plugins** > **Python Console**
  
 Click '​**Show Editor**'​ Click '​**Show Editor**'​
Line 135: Line 138:
 {{https://​pmc.editing.wiki/​images/​Ross-QGIS-Tutorial-03.png}} {{https://​pmc.editing.wiki/​images/​Ross-QGIS-Tutorial-03.png}}
  
-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%%'''​%%gdalwarp **-t_srs EPSG:​32620** -wo SOURCE_EXTRA=1000 **-tr 5.0 5.0** -srcnodata "​-9999"​ -r cubic -of GTiff **-te 576787.687480 1841104.815839 597267.687480 1861584.815839 D:/​Arma/​Heightmaps/​Opentopo/​output_srtm.asc** **D:/​Arma/​QGIS/​Montserrat/​converted.tif**%%'''​%%)+os.system(r%%'''​%%gdalwarp ​**-t_srs EPSG:​32620** -wo SOURCE_EXTRA=1000 **-tr 5.0 5.0** -srcnodata "​-9999"​ -r cubic -of GTiff **-te 576787.687480 1841104.815839 597267.687480 1861584.815839 D:/​Arma/​Heightmaps/​Opentopo/​output_srtm.asc** **D:/​Arma/​QGIS/​Montserrat/​converted.tif**%%'''​%%)
  
 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://​pmc.editing.wiki/​images/​Ross-QGIS-Tutorial-04.png}} {{https://​pmc.editing.wiki/​images/​Ross-QGIS-Tutorial-04.png}}
  
 **-te 576787.687480 1841104.815839 597267.687480 1861584.815839**\\ **-te 576787.687480 1841104.815839 597267.687480 1861584.815839**\\
-The 4 long figures represent ​the **extents** of your square, and should be replaced with your own figures obtained in previous step.+The 4 long figures represent ​the **extents** of your square, and should be replaced with your own figures obtained in previous step.
  
 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:/​Arma/​Heightmaps/​Opentopo/​output_srtm.asc**  use double quotes around your input path if it contains any blanks+**D:/​Arma/​Heightmaps/​Opentopo/​output_srtm.asc** ​ use double quotes around your input path if it contains any blanks
  
 Output:\\ Output:\\
Line 164: Line 167:
  
 **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%%'''​%%gdal_translate -of AAIGrid D:/​Arma/​QGIS/​Montserrat/​converted.tif D:/​Arma/​QGIS/​Montserrat/​final.asc%%'''​%%)+os.system(r%%'''​%%gdal_translate -of AAIGrid ​**D:/​Arma/​QGIS/​Montserrat/​converted.tif D:/​Arma/​QGIS/​Montserrat/​final.asc**%%'''​%%)
  
  
Line 173: Line 178:
 ==== For single tile export ==== ==== For single tile export ====
  
-**Load in just the .map files into QGIS**+**Load in just the '.map' ​files generated from Terra incognita ​into QGIS**
  
 {{https://​pmc.editing.wiki/​images/​Ross-QGIS-Tutorial-1b.png}} {{https://​pmc.editing.wiki/​images/​Ross-QGIS-Tutorial-1b.png}}
Line 179: Line 184:
 **Merge Rasters** **Merge Rasters**
  
-Top Menu -** Raster **→ **Miscellaneous **→ **Merge**+Top Menu -** Raster ​**→ **Miscellaneous ​**→ **Merge**
  
 Select all your .map files as input layers Select all your .map files as input layers
Line 185: Line 190:
 {{https://​pmc.editing.wiki/​images/​Ross-QGIS-Tutorial-3b.png}} {{https://​pmc.editing.wiki/​images/​Ross-QGIS-Tutorial-3b.png}}
  
-change **Output data type** to ‘Byte’ as the default is ‘Float32’.+change ​**Output data type** to ‘Byte’ as the default is ‘Float32’.
  
 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 198:
 **Obtain extents from square feature** **Obtain extents from square feature**
  
-You should already have this from working on heightmap ​above   **576787.687480 1841104.815839 597267.687480 1861584.815839**+You should already have this from working on heightmap ​above   **576787.687480 1841104.815839 597267.687480 1861584.815839**
  
 **Run GDAL command** **Run GDAL command**
  
 import os\\ import os\\
-os.system(r%%'''​%%gdalwarp **-t_srs EPSG:​32620** -r cubic -wo SOURCE_EXTRA=1000 **-tr 1.0 1.0** -r cubic -of BMP **-te 576787.687480 1841104.815839 597267.687480 1861584.815839** D:/​Arma/​QGIS/​Montserrat/​merged.tif D:/​Arma/​QGIS/​Montserrat/​mont.bmp%%'''​%%)+os.system(r%%'''​%%gdalwarp ​**-t_srs EPSG:​32620** -r cubic -wo SOURCE_EXTRA=1000 **-tr 1.0 1.0** -r cubic -of BMP **-te 576787.687480 1841104.815839 597267.687480 1861584.815839** D:/​Arma/​QGIS/​Montserrat/​merged.tif D:/​Arma/​QGIS/​Montserrat/​mont.bmp%%'''​%%)
  
 Some explanation of the key parameters: Some explanation of the key parameters:
Line 224: Line 229:
 **Create grid -- 2 x 2 Feature** **Create grid -- 2 x 2 Feature**
  
-You will need to have created ​the **square shapefile** first -- see above steps+You will need to have created ​the **square shapefile** first -- see above steps
  
-Top Menu -- **View** → **Panels** → **Processing Toolbox**+Top Menu -- **View** → **Panels** → **Processing Toolbox**
  
-Processing Toolbox Menu -- **Vector Creation** >​ **Create Grid**+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 241:
 {{https://​pmc.editing.wiki/​images/​Ross-QGIS-Tutorial-26b.png}} {{https://​pmc.editing.wiki/​images/​Ross-QGIS-Tutorial-26b.png}}
  
-Select the shapefile layer for your square+After clicking '**Use Layer Extent**' ​Select the shapefile layer for your square
  
 {{https://​pmc.editing.wiki/​images/​Ross-QGIS-Tutorial-13.png}} {{https://​pmc.editing.wiki/​images/​Ross-QGIS-Tutorial-13.png}}
  
-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 ​**Run**, your original square will then be Covered with a new grid of 4 tiles -- perfect quarters of your original square
  
 {{https://​pmc.editing.wiki/​images/​Ross-QGIS-Tutorial-30b.png}} {{https://​pmc.editing.wiki/​images/​Ross-QGIS-Tutorial-30b.png}}
Line 248: Line 253:
 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://​pmc.editing.wiki/​images/​Ross-QGIS-Tutorial-31.png}} {{https://​pmc.editing.wiki/​images/​Ross-QGIS-Tutorial-31.png}}
Line 256: Line 261:
 {{https://​pmc.editing.wiki/​images/​Ross-QGIS-Tutorial-32b.png}} {{https://​pmc.editing.wiki/​images/​Ross-QGIS-Tutorial-32b.png}}
  
-Top Menu -- **Edit** >​ **Copy Features**+Top Menu -- **Edit** > **Copy Features**
  
-Then… **Edit** → **Paste Features ​As **→ **New Vector Layer**+Then… **Edit** → **Paste Features ​As **→ **New Vector Layer**
  
 Save shapefile layer to something obvious Save shapefile layer to something obvious
Line 284: Line 289:
 And list them out for safe keeping - And list them out for safe keeping -
  
-TL -  Extent: (576787.687480,​ 1851344.815839) - (587027.687480,​ 1861584.815839)\\ +TL -  Extent: (576787.687480,​ 1851344.815839) - (587027.687480,​ 1861584.815839)\\ 
-TR -  Extent: (587027.687480,​ 1851344.815839) - (597267.687480,​ 1861584.815839)\\ +TR -  Extent: (587027.687480,​ 1851344.815839) - (597267.687480,​ 1861584.815839)\\ 
-BL -  Extent: (576787.687480,​ 1841104.815839) - (587027.687480,​ 1851344.815839)\\+BL -  Extent: (576787.687480,​ 1841104.815839) - (587027.687480,​ 1851344.815839)\\
 BR - Extent: (587027.687480,​ 1841104.815839) - (597267.687480,​ 1851344.815839)\\ BR - Extent: (587027.687480,​ 1841104.815839) - (597267.687480,​ 1851344.815839)\\
  
Line 330: Line 335:
   * Road shapefile creation   * Road shapefile creation
   * Assisted image classification - for creation of mask   * Assisted image classification - for creation of mask
-  * 3d preview ​using Qgis2threejs+  * 3d preview ​using Qgis2threejs
arma3/terrain/qgis-real-world-data-tutorial.txt · Last modified: 2022-01-04 05:59 by snakeman