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
Previous revision
arma3:terrain:qgis-real-world-data-tutorial [2018-07-28 07:19]
snakeman shorter headers.
arma3:terrain:qgis-real-world-data-tutorial [2022-01-04 05:59] (current)
snakeman opentopo 404 link and typos fixed.
Line 3: Line 3:
 ArmA 3 QGIS Real World Data Tutorial By Ross ArmA 3 QGIS Real World Data Tutorial By Ross
  
-**__Using QGIS to export satellite image ready for Terrain Builder project__**+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.
  
-This process has often been described using Global Mapper, but I wanted to detail the equivalent steps within the open source GIS app **QGIS******+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 goal is to achieve an export image with the same or better quality than would be possible ​with Global Mapper+I've used GDAL command lines where possible, which simplifies the process a little, and reduced additional processing on the data.
  
-The visual below shows an example of the 2 processing routes I reviewed to check loss of image quality due to compression and reprojections+The following software versions were used for this tutorial:
  
-I will detail ​**Route A** - because it only requires 1 compression and reprojection pass over the raster which may help preserve image quality+**[[https://​qgis.org/​en/​site/​forusers/​download.html|QGIS v3.4.3]]**
  
-**{{ https://pmc.editing.wiki/images/Ross-QGIS-Tutorial-process.png }}**+**[[https://sourceforge.net/​projects/​terraincognita2/files/|Terra Incognita v2.45]]**
  
-__Software required:__+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.
  
-**[[satellite-texture-terra-incognita|Terra Incognita]]**+**First an overview of the steps required:**
  
-**[[https://​qgis.org/​en/​site/​forusers/​download.html|QGIS 3.2.0]]**+==== For Heightmap====
  
-**__Brief overview ​of steps:__**+  ​Load heightmap into QGIS (drag and drop) 
 +  ​Set QGIS to appropriate CRS for location ​of your HM 
 +  ​Create shapefile & generate perfect square using Advanced Digitizing panel 
 +  ​Obtain extents from square feature 
 +  * Run 2 GDAL commands 
 +    * First to set cell size, CRS and then clip to shapefile square extents 
 +    * Second to convert to .asc file 
 + 
 + 
 +==== For Satellite image ====
  
 **For single tile export** **For single tile export**
-  * Load in just the .map files into QGIS 
-  * Merge Rasters 
-  * Align raster to 1mtr cell size and re-project to appropriate CRS for its geo location 
-  * Change the ‘Project Coordinate Reference System’ (CRS) to match CRS in previous step 
-  * Create shapefile layer 
-  * Create square Feature using Advanced Digitizing panel 
-  * Export sat image ready for Terrain Builder using ‘clip raster by mask layer’ 
  
-**For 4 tile export** +  * Load in just the '​.map'​ files generated from Terra Incognita into QGIS 
-  * Load in just the .map files into QGIS+  * Merge rasters 
 +  * Obtain extents from square feature 
 +  * gdalwarp command will set cell size, CRS and then clip to shapefile square extents 
 + 
 +**For 4 tile export ​(large projects 40960 and above)** 
 + 
 +  * Load in just the '.map' ​files generated from Terra Incognita ​into QGIS
   * Merge Rasters   * Merge Rasters
-  * Align raster to 1mtr cell size and re-project to appropriate CRS for its geo location 
-  * Change the ‘Project Coordinate Reference System’ (CRS) to match CRS in previous step 
-  * Create shapefile layer 
   * 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
-  * Export 4 sat images ready for Terrain Builder using ‘clip raster by mask layer’+  * Obtain extents from each quarter feature 
 +  * Run gdalwarp command ​for each quarter to set cell size and CRS and clip to shapefile square extents
  
-I shall primarily focus on the steps for generating a single tile export, but will explain additional steps required for a 4 tile export at the end -- which would suit those terrains that are 40960px x 40960px and higher.+**And now detailed ​steps for:**
  
  
-====== Load just the .map files into QGIS ======+===== Heightmap: ​=====
  
-Terra Incognita ​will generate tiled images with corresponding ​.map files, these .map files hold the CRS details within themYou will only need to drag the **.map** files into QGIS’s central paneThey will automatically link back to the images ​(jpg’s, tif’s), located where you originally saved them.+This tutorial covers single raster heightmap as per the kind you will find on [[https://​portal.opentopography.org/​raster?​opentopoID=OTSRTM.082015.4326.1|opentopo]],​ I will detail steps for heightmaps spread across multiple rasters in another update. as they will require additional steps likely including Merge / Build Virtual Raster commands. This section does not cover any re scaling of heightmap, which I would recommend against anyway. Remember [[https://​pmc.editing.wiki/​doku.php?​id=arma:​terrain:​grid_cell_size|Grid size x Cell size]] should = the same size (metersas your source heightmap selection.
  
-{{ https://pmc.editing.wiki/​images/​Ross-QGIS-Tutorial-1.png }}+**Drag and drop your heightmap '.asc' into QGIS**
  
 +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.
  
-====== Merge raster’s ======+**Set QGIS to appropriate CRS for location of your HM**
  
-Top Menu **Raster** ​-> **Miscellaneous** -> **Merge**+Clicking on the CRS section bottom right within QGIS -- will bring up the Project Properties for CRS
  
-Select all your **.map** files as input layers+{{https://​pmc.editing.wiki/​images/​Ross-QGIS-Tutorial-11b.png}}
  
-{{ https://​pmc.editing.wiki/​images/Ross-QGIS-Tutorial-2.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]].\\ 
-{{ https://​pmc.editing.wiki/​images/​Ross-QGIS-Tutorial-3.png }}+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.
  
-Don’t forget to change **Output data type** to ‘Byte’ as the default is ‘Float32’.+{{https://​pmc.editing.wiki/​images/​Ross-QGIS-Tutorial-13b.png}}
  
-**Select ‘Save to File’** under Merged -- as the default is to a temporary file.+**Create shapefile & generate square feature using Advanced Digitizing panel**
  
-Stitching together a collection of .map files is fairly simple using the **Merge** function, depending on the size of your project it will however create large .tif exports. The example above generated a .tif file of 5.42GB -- for an area that covers approx 40 x 40km. This took 36 minutes to complete the processing, so be patient.** **+Top menu -- **Layer **> **Create Layer** > **New Shapefile Layer**
  
-**Once complete you will get confirmation and the time taken to process in the Log tab:**+Save to project folder location
  
-{{ https://​pmc.editing.wiki/​images/​Ross-QGIS-Tutorial-4.png }}+Change Geometry type to ‘Polygon’
  
 +Match CRS so it is the same as that just configured in above step
  
-====== Align raster to 1mtr cell size and re-project to correct CRS ======+{{https://​pmc.editing.wiki/​images/​Ross-QGIS-Tutorial-14b.png}}
  
-I am working towards a cell size of **1m** - so within **Terrain Builder** ​in my ‘**Mapframe Properties**’ you would find this >+Right click on your shapefile ​in layers window & select ​‘**Toggle Editing**’
  
-{{ https://​pmc.editing.wiki/​images/​Ross-QGIS-Tutorial-5.png }}+{{https://​pmc.editing.wiki/​images/​Ross-QGIS-Tutorial-15b.png}}
  
-The reason we have to align raster to 1m cell size within QGIS is because even though Terra Incognita is saying+From menu -- **View** → **Toolbars** → **Advanced Digitizing Toolbar**
  
-it’s generating exports at - **1m/px** > +{{https://​pmc.editing.wiki/​images/​Ross-QGIS-Tutorial-16.png}}
-{{ https://​pmc.editing.wiki/​images/​Ross-QGIS-Tutorial-6.png }}+
  
-If you double click on one of your .map raster’s in QGIS **Layers panel** you will see in the **Information** tab that its not exactly 1m  > +Select ‘**Add Polygon Feature**’
-{{ https://​pmc.editing.wiki/​images/​Ross-QGIS-Tutorial-7.png }}+
  
-Top Menu -- **Raster > Align Rasters** Add the raster generated in the previous **Merge raster’s** step:+{{https://​pmc.editing.wiki/​images/​Ross-QGIS-Tutorial-17.png}}
  
-{{ https://​pmc.editing.wiki/​images/​Ross-QGIS-Tutorial-8.png }}+Select Enable advanced digitizing tools
  
-Tick both **CRS** and **Cell Size:**+{{https://​pmc.editing.wiki/​images/​Ross-QGIS-Tutorial-18.png}}
  
-{{ https://​pmc.editing.wiki/​images/​Ross-QGIS-Tutorial-9.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.
  
-Change settings to suite your cell size and appropriate CRS projection:+{{https://​pmc.editing.wiki/​images/​Ross-QGIS-Tutorial-19b.png}}
  
-{{ https://​pmc.editing.wiki/​images/​Ross-QGIS-Tutorial-10.png }}+See a short video example using the **Advanced Digitizing** tool:
  
 +{{https://​pmc.editing.wiki/​images/​Ross-QGIS-Tutorial-AdvancedDigitizing.gif}}
  
-====== Change ​the ‘Project Coordinate Reference System’ (CRS) ======+After the last **left mouse click** from the step above, the tool is still waiting to plot more points, so to finalize the square do a **right mouse click**
  
-Clicking on the CRS section bottom right within ​QGIS -- will bring up the Project Properties for CRS+{{https://​pmc.editing.wiki/​images/​Ross-QGIS-Tutorial-20b.png}}
  
-{{ https://​pmc.editing.wiki/​images/​Ross-QGIS-Tutorial-11.png }}+This will then bring up an attributes dialogue ​-- just type any number and Enter
  
-It will probably be on a Generated CRS which looks something like this:+{{https://​pmc.editing.wiki/​images/​Ross-QGIS-Tutorial-21.png}}
  
-{{ https://​pmc.editing.wiki/​images/​Ross-QGIS-Tutorial-12.png }}+Save the above edits to the shapefile by clicking on the layer & selecting ‘**Toggle Editing**’
  
-Select the **CRS** to match the same selected in previous **Align** Step, in this example its ‘**WGS 84 UTM zone 30N’** because the terrain is from the United Kingdom. See also [[utm-projection|UTM projection]].+**Obtain extents from square feature**
  
-{{ https://​pmc.editing.wiki/​images/​Ross-QGIS-Tutorial-13.png }}+Activate the toolbox if it is not already available
  
 +{{https://​pmc.editing.wiki/​images/​Ross-QGIS-Tutorial-12.png}}
  
-====== Create shapefile layer ======+Start typing '​**vector**'​ in Processing Toolbox search bar, and you will see '​**Vector information**'​
  
-Top menu -- **Layer** > **Create Layer** > **New Shapefile Layer**+Double click it and make sure your square ​**input layer** is selected - then just click **Run**
  
-Change **Geometry type** to ‘Polygon’+{{https://​pmc.editing.wiki/​images/​Ross-QGIS-Tutorial-01.png}}
  
-{{ https://​pmc.editing.wiki/​images/​Ross-QGIS-Tutorial-14.png }}+You will only need to copy the **Extent** figures, which we will use within the GDAL commands in the next step
  
-Right click on shapefile & select ‘**Toggle Editing’**+{{https://​pmc.editing.wiki/​images/​Ross-QGIS-Tutorial-02.png}}
  
-{{ https://​pmc.editing.wiki/​images/​Ross-QGIS-Tutorial-15.png }}****** **+**Run the first GDAL command which will - set CRS, cell size and then clip to shapefile square extents**
  
 +From menu - **Plugins** > **Python Console**
  
-====== Create square using Advanced Digitizing panel ======+Click '​**Show Editor**'​
  
-From menu -- **View** ​-> **Toolbars** -> **Advanced Digitizing Toolbar**+{{https://​pmc.editing.wiki/​images/​Ross-QGIS-Tutorial-03.png}}
  
-{{ https://​pmc.editing.wiki/​images/​Ross-QGIS-Tutorial-16.png }}+The blank window on the right is where you will paste GDAL commands
  
-Select ‘**Add Polygon Feature**’****+Now you are ready to edit the command below to match your data - sections in bold are the parts to edit:
  
-{{ https://pmc.editing.wiki/images/Ross-QGIS-Tutorial-17.png }}+import os\\ 
 +os.system(r%%'''​%%gdalwarp -t_srs EPSG:​**32620** -wo SOURCE_EXTRA=1000 -tr **5.0 5.0** -srcnodata "​-9999"​ -r cubic -ot Float32 -of GTiff -te **576787.687480 1841104.815839 597267.687480 1861584.815839 D:/Arma/Heightmaps/​Opentopo/​output_srtm.asc** **D:/Arma/QGIS/​Montserrat/​converted.tif**%%'''​%%)
  
-Select **Enable advanced digitizing tools**+Some explanation of the key parameters:
  
-{{ https://​pmc.editing.wiki/​images/​Ross-QGIS-Tutorial-18.png }}+**-t_srs EPSG:32620 **\\ 
 +CRS to match where the heightmap is from in the world.
  
-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 ‘40960’) then immediately press **Enter** -- be careful not to move the mouse before pressing **Enter** or it will mess up the numberPress **left mouse click** and you will have drawn your first horizontal line which turns red. By default this tool snaps to 90 degree anglesmaking 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.+**-tr 5.0 5.0**\\ 
 +The desired resolution of your heightmapmatch with **Cell size** set within your Mapframe properties ​in Terrain Builder:
  
-{{ https://​pmc.editing.wiki/​images/​Ross-QGIS-Tutorial-19.png }}+{{https://​pmc.editing.wiki/​images/​Ross-QGIS-Tutorial-04.png}}
  
-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 a **right mouse click**+**-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.
  
-{{ https://pmc.editing.wiki/​images/​Ross-QGIS-Tutorial-20.png }}+Update the paths to match where you are storing your source heightmap, and where you want the output tif saved to.
  
-This will then bring up a dialogue -- just type any number and **Enter**+Input:\\ 
 +**D:/​Arma/​Heightmaps/​Opentopo/​output_srtm.asc**  use double quotes around your input path if it contains any blanks
  
-{{ https://pmc.editing.wiki/images/Ross-QGIS-Tutorial-21.png }}+Output:\\ 
 +**D:/Arma/QGIS/Montserrat/converted.tif**
  
-Because the new square ​**polygon feature** is filled with colour it’s hard to see your sat image behind, so I tend to double click on the shapefile in the layers panel on the left, and in the **Symbology** tab set the **Opacity** for both available options to 70%+**Run second GDAL command - converting tif from above step to Terrain Builder friendly .asc**
  
-{{ https://​pmc.editing.wiki/​images/​Ross-QGIS-Tutorial-22.png }}****** **+Remember to change the paths in below command to match where your files are located
  
-To move your square just select ​**Move Feature** and shift it to the desired position over your sat image+import os\\ 
 +os.system(r%%'''​%%gdal_translate -of AAIGrid ​**D:/​Arma/​QGIS/​Montserrat/​converted.tif D:/​Arma/​QGIS/​Montserrat/​final.asc**%%'''​%%)
  
-{{ https://​pmc.editing.wiki/​images/​Ross-QGIS-Tutorial-23.png }}****** ** 
  
-Once you have finished with your polygon feature, remember to right click on shapefile layer & click**‘Toggle editing’** so changes are saved to file.****+===== Satellite image =====
  
-{{ https://​pmc.editing.wiki/​images/​Ross-QGIS-Tutorial-24.png }}****** **+==== For single tile export ====
  
 +**Load in just the '​.map'​ files generated from Terra Incognita into QGIS**
  
-====== Export satellite image ready for Terrain Builder ======+{{https://​pmc.editing.wiki/​images/​Ross-QGIS-Tutorial-1b.png}}
  
-Menu -- **Raster** -> **Extraction** -> **Clip Raster by Mask Layer**+**Merge Rasters**
  
-**Input layer** - is the raster generated from the **Align Raster** step+Top Menu -** Raster ​**→ **Miscellaneous **→ **Merge**
  
-**Mask Layer** - is the shapefile created in the previous step+Select all your .map files as input layers
  
-Double check these are both the same CRS+{{https://​pmc.editing.wiki/​images/​Ross-QGIS-Tutorial-3b.png}}
  
-Change ​**Output data type** to ‘Byte’+change ​**Output data type** to ‘Byte’ ​as the default is ‘Float32’.
  
-Once your clipped file is saved, check the image dimensions match exactly to those defined in the **Create square** step.+Select ‘**Save to File**’ under Merged -- as the default is to a temporary file.
  
-When saving to **.bmp** (best format for Terrain Builder) you will find there is a 4GB hard limit.+{{https://​pmc.editing.wiki/​images/​Ross-QGIS-Tutorial-2b.png}}
  
-This will obviously be dictated by the size of your chosen terrain+**Obtain extents from square feature**
  
-If you keep under 4GB you can use a single square feature selection shown above+You should already have this from working on heightmap ​above   **576787.687480 1841104.815839 597267.687480 1861584.815839**
  
-If you are likely to breach the 4GB limit, you’ll need to look at 4 tiles for your feature selection.+**Run GDAL command**
  
-See below steps to generate 4 tiled feature selection.+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%%'''​%%)
  
-{{ https://​pmc.editing.wiki/​images/​Ross-QGIS-Tutorial-25.png }}+Some explanation of the key parameters:
  
 +**-t_srs EPSG:​32620**\\
 +Sets the CRS
  
-====== Create grid -- 2 x 2 Feature - ready to export sat image into 4 tiles ======+**-tr 1.0 1.0**\\ 
 +Sets the resolution of your satellite image to 1mtr per pixel which is recommended. Make sure it matches your settings within Terrain Builder.
  
-You will need to have created the **square feature** first -- see above steps+{{https://​pmc.editing.wiki/​images/​Ross-QGIS-Tutorial-05.png}}
  
-Top Menu -- **View** -> **Panels** -> **Processing Toolbox**+**-te 576787.687480 1841104.815839 597267.687480 1861584.815839**\\ 
 +Clips to shapefile square extents
  
-Processing Toolbox Menu -- **Vector Creation** > **Create Grid** 
  
-Set **Grid type** to ‘polygon’ & the **Horizontal** & **Vertical** to half the distance of your main square+==== For 4 tile export ====
  
-{{ https://​pmc.editing.wiki/​images/​Ross-QGIS-Tutorial-26.png }}+Detailing additional steps required for a 4 tile export ​-- which would suit those terrains that are 40960px x 40960px and higher.
  
-Select ​the shapefile created ​above for your main square+**Load in just the .map files into QGIS** 
 + 
 +**Merge rasters - same as above (single tile export)** 
 + 
 +**Create grid -- 2 x 2 Feature** 
 + 
 +You will need to have created the **square ​shapefile** first -- see above steps 
 + 
 +Top Menu -- **View** → **Panels** → **Processing Toolbox** 
 + 
 +Processing Toolbox Menu -- **Vector Creation** > **Create Grid**
  
-{{ https://​pmc.editing.wiki/​images/​Ross-QGIS-Tutorial-27.png }}+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
  
-{{ https://​pmc.editing.wiki/​images/​Ross-QGIS-Tutorial-28.png }}+{{https://​pmc.editing.wiki/​images/​Ross-QGIS-Tutorial-26b.png}}
  
-Your original ​square ​feature selection+After clicking '**Use Layer Extent**'​ Select the shapefile layer for your square
  
-{{ https://​pmc.editing.wiki/​images/​Ross-QGIS-Tutorial-29.png }}+{{https://​pmc.editing.wiki/​images/​Ross-QGIS-Tutorial-13.png}}
  
-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-30.png }}+{{https://​pmc.editing.wiki/​images/​Ross-QGIS-Tutorial-30b.png}} 
 + 
 +**Move each quarter to 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. 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}}
  
 And select the first quarter: And select the first quarter:
  
-{{ https://​pmc.editing.wiki/​images/​Ross-QGIS-Tutorial-32.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 239: Line 271:
 I’ve used ‘**TL**’ for top left. I’ve used ‘**TL**’ for top left.
  
-{{ https://​pmc.editing.wiki/​images/​Ross-QGIS-Tutorial-33.png }}+{{https://​pmc.editing.wiki/​images/​Ross-QGIS-Tutorial-33b.png}} 
 + 
 +Repeat for the remaining quarters and you’ll have something like below, ‘Grid’ can be deleted. 
 + 
 +{{https://​pmc.editing.wiki/​images/​Ross-QGIS-Tutorial-34b.png}} 
 + 
 +You will then have 4 tiles which we can use to gather each quarters extents 
 + 
 +{{https://​pmc.editing.wiki/​images/​Ross-QGIS-Tutorial-35b.png}} 
 + 
 +**Obtain extents from each quarter feature** 
 + 
 +{{https://​pmc.editing.wiki/​images/​Ross-QGIS-Tutorial-06.png}} 
 + 
 +Copy extents to clipboard 
 + 
 +{{https://​pmc.editing.wiki/​images/​Ross-QGIS-Tutorial-07.png}} 
 + 
 +And list them out for safe keeping - 
 + 
 +**TL -  Extent**: (576787.687480,​ 1851344.815839) - (587027.687480,​ 1861584.815839)\\ 
 +**TR -  Extent**: (587027.687480,​ 1851344.815839) - (597267.687480,​ 1861584.815839)\\ 
 +**BL -  Extent**: (576787.687480,​ 1841104.815839) - (587027.687480,​ 1851344.815839)\\ 
 +**BR - Extent**: (587027.687480,​ 1841104.815839) - (597267.687480,​ 1851344.815839)\\ 
 + 
 +**Run GDAL command for each quarter to set cell size and CRS and clip to shapefile square extents** 
 + 
 +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/​**TR.bmp**%%'''​%%) 
 + 
 + 
 +===== 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** 
 + 
 +Open your **asc** in notepad and change the following to ensure it loads in **Terrain builder**:​ 
 + 
 +{{https://​pmc.editing.wiki/​images/​Ross-QGIS-Tutorial-14.png}} 
 + 
 +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://​pmc.editing.wiki/​images/​Ross-QGIS-Tutorial-09.png}} 
 + 
 +**Satellite image** 
 + 
 + 
 +Before loading the satellite image into Terrain Builder delete the .bmp.aux file 
 + 
 +{{https://​pmc.editing.wiki/​images/​Ross-QGIS-Tutorial-08.png}} 
 + 
 + 
 +===== Managing the project assets within QGIS ===== 
 + 
 + 
 +Save your QGIS project so that you can return to export further data at a later date. 
 + 
 + 
 +Layers can be tidied up to hold the essentials ready for the next time you want to re-run GDAL commands, or export anything else like road shapefiles or mask layers etc. 
 + 
 + 
 +{{https://​pmc.editing.wiki/​images/​Ross-QGIS-Tutorial-11.png}} 
 + 
 +===== Preparing Road Shapefile ===== 
 + 
 +**Load into QGIS (drag and drop) road shapefile** 
 + 
 +In this example I got a good dataset from - [[https://​data.humdata.org/​|https://​data.humdata.org/​]] 
 + 
 +{{https://​pmc.editing.wiki/​images/​Ross-QGIS-Tutorial-37.png}} 
 + 
 +**Clip vector to square shape** 
 +Top Menu - **Vector** > **Geoprocessing Tools** > **Clip** 
 + 
 +{{https://​pmc.editing.wiki/​images/​Ross-QGIS-Tutorial-38.png}} 
 + 
 +Save features from clip to new shapefile -  selecting appropriate CRS, in this example **CRS UTM-20**\\ 
 + 
 +Top Menu - **Layer** > **Save As** 
 + 
 +{{https://​pmc.editing.wiki/​images/​Ross-QGIS-Tutorial-39.png}} 
 + 
 +**Set road shapefile to CRS - 31N** 
 + 
 +RMB on road shapefile > **Set CRS** > **Set Layer CRS** 
 + 
 +{{https://​pmc.editing.wiki/​images/​Ross-QGIS-Tutorial-40.png}} 
 + 
 +{{https://​pmc.editing.wiki/​images/​Ross-QGIS-Tutorial-41.png}} 
 + 
 +**Set QGIS project CRS to UTM- 31N (bottom right corner):​** 
 + 
 +{{https://​pmc.editing.wiki/​images/​Ross-QGIS-Tutorial-42.png}} 
 + 
 +**Collect extents from your square shapefile:​** 
 + 
 +{{https://​pmc.editing.wiki/​images/​Ross-QGIS-Tutorial-43.png}} 
 + 
 +Extent: (**576787.687480**,​ **1841104.815839**) - (597267.687480,​ 1861584.815839) 
 + 
 +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 of **easting 200000** and **northing 0** 
 +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: ​ 576787.687480 ​ - 376787.68748 = 200000**\\ 
 +**Northing: 1841104.815839 - 1841104.815839 = 0**\\ 
 + 
 +**-376787.68748**\\ 
 +**-1841104.815839** 
 + 
 + 
 +Having figured out the correct figures plug them into the **v.transform** process 
 + 
 +{{https://​pmc.editing.wiki/​images/​Ross-QGIS-Tutorial-44.png}} 
 + 
 +Drag and Drop into QGIS your heightmap asc - the one you are able to load into Terrain builder - already adjusted to (**200000**,​ **0**) 
 + 
 +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://​pmc.editing.wiki/​images/​Ross-QGIS-Tutorial-45.png}} 
 + 
 +Your roads should now be perfectly aligned above your heightmap 
 + 
 +{{https://​pmc.editing.wiki/​images/​Ross-QGIS-Tutorial-46.png}} 
 + 
 +==== 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://​pmc.editing.wiki/​images/​Ross-QGIS-Tutorial-47.png}} 
 + 
 +New Field - Name '​**ID**'​ - length **0** 
 + 
 +{{https://​pmc.editing.wiki/​images/​Ross-QGIS-Tutorial-48.png}} 
 + 
 +New Field - Name '​**ORDER**'​ - length 0 
 + 
 +{{https://​pmc.editing.wiki/​images/​Ross-QGIS-Tutorial-49.png}} 
 + 
 +Toggle - **Multi Edit mode** 
 + 
 +{{https://​pmc.editing.wiki/​images/​Ross-QGIS-Tutorial-50.png}} 
 + 
 +ID - Enter **0** - click **Update All** 
 + 
 +{{https://​pmc.editing.wiki/​images/​Ross-QGIS-Tutorial-51.png}} 
 + 
 +Select ORDER from drop down - Enter **1** - click **Update all** 
 + 
 +{{https://​pmc.editing.wiki/​images/​Ross-QGIS-Tutorial-52.png}} 
 + 
 +Click - **Switch to table view** 
 + 
 +{{https://​pmc.editing.wiki/​images/​Ross-QGIS-Tutorial-53.png}} 
 + 
 +Click **Save** 
 + 
 +{{https://​pmc.editing.wiki/​images/​Ross-QGIS-Tutorial-54.png}} 
 + 
 +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://​pmc.editing.wiki/​images/​Ross-QGIS-Tutorial-55.png}} 
 + 
 +Perfectly overlaid within **Terrain builder:​** 
 + 
 +{{https://​pmc.editing.wiki/​images/​Ross-QGIS-Tutorial-56.png}} 
 + 
 +===== 3D Preview using Qgis2threejs ===== 
 + 
 +If you want to see an instant 3d preview of your terrain within QGIS you can with the amazing plugin **Qgis2threejs** 
 + 
 +First install it:
  
-Repeat for the remaining quarters and you’ll have something like below, ‘**Grid**’ can be deleted.+Top menu > **Plugins** > **Manage and Install Plugins**
  
-{{ https://​pmc.editing.wiki/​images/​Ross-QGIS-Tutorial-34.png }}+{{https://​pmc.editing.wiki/​images/​Ross-QGIS-Tutorial-57.png}}
  
-You will then have 4 tiles ready for reference in clip+RMB on the Merged layer and select **Zoom to Layer**
  
-{{ https://​pmc.editing.wiki/​images/​Ross-QGIS-Tutorial-35.png }}+Then select both the **Merged** raster, and the original source heightmap ​deselect all other layers
  
-I’d recommend configuring the new tiles opacity as mentioned in the previous **Create square** step.+{{https://​pmc.editing.wiki/​images/​Ross-QGIS-Tutorial-58.png}}
  
 +Start the Qgis2threejs plugin - Top Menu > **Web** > **Qgis2threejs** > **Qgis2threejs Exporter**
  
-====== Export satellite ​images ​(tiled) ready for Terrain Builder ======+{{https://​pmc.editing.wiki/​images/​Ross-QGIS-Tutorial-59.png}}
  
-The following steps will need to be repeated 4 times in order to export your 4 quarters.+Select source heightmap and nothing else
  
-Menu -- **Raster** -> **Extraction** -> **Clip Raster by Mask Layer**+RMB on heightmap ​> **Properties**
  
-**Input layer** - is the raster generated from the **Align Raster** step+Set the **Resampling** level to **6**
  
-**Mask Layer** - select each quarter, until you have extracted all 4+Set **Resolution** to **400%**
  
-Change **Output data type** to ‘Byte’+{{https://​pmc.editing.wiki/​images/​Ross-QGIS-Tutorial-60.png}}
  
-{{ https://​pmc.editing.wiki/​images/​Ross-QGIS-Tutorial-36.png }}+Enjoy browsing around your terrain in 3D:
  
-Once your clipped file is saved, check the image dimensions are exactly half of those defined in the **Create square** stepIn this example it would be 20480px+{{https://​pmc.editing.wiki/​images/​Ross-QGIS-Tutorial-61.png}}
  
-These 4 tiled sat images ​can then be brought together in Terrain builder using **Layers**.+You can also export your terrain to a browser interface if you want - **File** > **Export to web**
  
-[[import-satellite-in-smaller-tiles|Import satellite in smaller tiles]] 
arma3/terrain/qgis-real-world-data-tutorial.1532762362.txt.gz · Last modified: 2018-07-28 07:19 by snakeman