This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
arma3:terrain:qgis-real-world-data-tutorial [2019-02-11 02:57] snakeman added new update from ross. |
arma3:terrain:qgis-real-world-data-tutorial [2022-01-04 05:59] (current) snakeman opentopo 404 link and typos fixed. |
||
---|---|---|---|
Line 7: | Line 7: | ||
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 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! | + | I've used GDAL command lines where possible, which simplifies the process a little, and reduced additional 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. | + | The following software versions were used for this tutorial: |
- | + | ||
- | 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]]** | ||
Line 54: | Line 52: | ||
===== Heightmap: ===== | ===== Heightmap: ===== | ||
+ | |||
+ | 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 (meters) as your source heightmap selection. | ||
**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. | + | 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 66: | Line 66: | ||
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. |
{{https://pmc.editing.wiki/images/Ross-QGIS-Tutorial-13b.png}} | {{https://pmc.editing.wiki/images/Ross-QGIS-Tutorial-13b.png}} | ||
Line 106: | Line 106: | ||
{{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 a **right mouse click** | + | 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** |
{{https://pmc.editing.wiki/images/Ross-QGIS-Tutorial-20b.png}} | {{https://pmc.editing.wiki/images/Ross-QGIS-Tutorial-20b.png}} | ||
Line 113: | Line 113: | ||
{{https://pmc.editing.wiki/images/Ross-QGIS-Tutorial-21.png}} | {{https://pmc.editing.wiki/images/Ross-QGIS-Tutorial-21.png}} | ||
+ | |||
+ | 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 143: | Line 145: | ||
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 -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**%%'''%%) |
Some explanation of the key parameters: | Some explanation of the key parameters: | ||
Line 178: | Line 180: | ||
==== For single tile export ==== | ==== For single tile export ==== | ||
- | **Load in just the '.map' files generated from Terra incognita 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 289: | Line 291: | ||
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)\\ |
**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 302: | Line 304: | ||
===== 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** in notepad and change the following to ensure it loads in Terrain builder: | + | 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}} | {{https://pmc.editing.wiki/images/Ross-QGIS-Tutorial-14.png}} | ||
Line 311: | Line 314: | ||
Save to a new asc, whilst maintaining the original for use in your QGIS project space | 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. | + | 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}} | {{https://pmc.editing.wiki/images/Ross-QGIS-Tutorial-09.png}} | ||
Line 318: | Line 321: | ||
- | Before loading the satellite image into Terrrain Builder delete the .bmp.aux file | + | Before loading the satellite image into Terrain Builder delete the .bmp.aux file |
{{https://pmc.editing.wiki/images/Ross-QGIS-Tutorial-08.png}} | {{https://pmc.editing.wiki/images/Ross-QGIS-Tutorial-08.png}} | ||
Line 336: | Line 339: | ||
===== Preparing Road Shapefile ===== | ===== Preparing Road Shapefile ===== | ||
- | **Load in 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}} | {{https://pmc.editing.wiki/images/Ross-QGIS-Tutorial-37.png}} | ||
Line 345: | Line 350: | ||
{{https://pmc.editing.wiki/images/Ross-QGIS-Tutorial-38.png}} | {{https://pmc.editing.wiki/images/Ross-QGIS-Tutorial-38.png}} | ||
- | Save features from clip to new shapefile - selecting correct **CRS UTM-20**\\ | + | Save features from clip to new shapefile - selecting appropriate CRS, in this example **CRS UTM-20**\\ |
Top Menu - **Layer** > **Save As** | Top Menu - **Layer** > **Save As** | ||
Line 461: | Line 466: | ||
{{https://pmc.editing.wiki/images/Ross-QGIS-Tutorial-56.png}} | {{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: | ||
+ | |||
+ | Top menu > **Plugins** > **Manage and Install Plugins** | ||
+ | |||
+ | {{https://pmc.editing.wiki/images/Ross-QGIS-Tutorial-57.png}} | ||
+ | |||
+ | 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://pmc.editing.wiki/images/Ross-QGIS-Tutorial-58.png}} | ||
+ | |||
+ | Start the Qgis2threejs plugin - Top Menu > **Web** > **Qgis2threejs** > **Qgis2threejs Exporter** | ||
+ | |||
+ | {{https://pmc.editing.wiki/images/Ross-QGIS-Tutorial-59.png}} | ||
+ | |||
+ | Select source heightmap and nothing else | ||
+ | |||
+ | RMB on heightmap > **Properties** | ||
+ | |||
+ | Set the **Resampling** level to **6** | ||
+ | |||
+ | Set **Resolution** to **400%** | ||
+ | |||
+ | {{https://pmc.editing.wiki/images/Ross-QGIS-Tutorial-60.png}} | ||
+ | |||
+ | Enjoy browsing around your terrain in 3D: | ||
+ | |||
+ | {{https://pmc.editing.wiki/images/Ross-QGIS-Tutorial-61.png}} | ||
+ | |||
+ | You can also export your terrain to a browser interface if you want - **File** > **Export to web** | ||
- | **Coming Soon:** | ||
- | * Assisted image classification - for creation of mask | ||
- | * 3d preview using Qgis2threejs |