- Table of Contents
- Terrain Generation
- Terrain Generation (QGIS 3.4+)
- Manual generation of river water polygons
Table of contents generated with markdown-toc
This guide will show you how to generate a terrain file for any airport in openScope. This is mainly done using QGIS, a free and open source Geographic Information System. The process can be quite tedious and often frustrating, so if you get stuck somewhere, you can talk to us on Slack, where we will be happy to help you!
Download and install QGIS from the QGIS website
Note: QGIS version 3 is not compatible with the Zonal Statistics plugin.
- Open QGIS and navigate to
Plugins->Manage and install plugins...
- Search for
Zonal statistics plugin
and enable plugin
- The folder should be named after the airport's ICAO code, e.g.
~/KSEA/
Note: Throughout this guide it will be referred to as~/terrain/
- Go to this site and download all the tiles which cover your airport and its surrounding area
- Extract the zip files into a new folder
~/terrain/DEM/
- Copy all the coordinates within the airspace key of your airport file
- Convert the coordinates to the right format using this web app (Thanks @jakcharvat for this wonderful tool!)
- Copy the output and paste it on a new file.
- Save the file as
~/terrain/airspace.csv/
- Go to
Raster->Miscellaneous->Build Virtual Raster(Catalog)...
- Check
Choose input directory instead of files
- For input directory select
~/terrain/DEM/
- Check
Recurse subdirectories
- For Output file select
~/terrain/dem.vrt
- Check
Load into canvas when finished
- Click
OK
Note: After it completes, click OK
on the popups and Close
on the Build Virtual Raster window.
-
In QGIS, go to
Layer->Add Layer->Add Delimited Text Layer...
-
For
File Name
browse~/terrain/airspace.csv/
-
For
File Format
checkCustom Delimiters
-
For
Geometry Definition
checkWell Known Text (WKT)
-
Click
OK
-
Go to
Vector->Geometry Tools->Polygons to Lines...
-
Input layer:
airspace
-
Click
Run
-
On the Layers Panel, Rename
Lines from polygons
toperimeter
-
Go to
Vector->Geoprocessing Tools->Fixed distance buffer
-
Input layer:
airspace
-
Distance:
0.005
-
Click
Run
-
Go to
Processing->Toolbox
-
Search for
Clip raster by mask layer
-
Input layer:
dem
-
Mask Layer:
Buffer
-
Click
Run
Note: QGIS may seem frozen while the algorithm is run, but it is still running. Try not clicking anywhere on the program to ensure it does not crash.
-
Go to
Vector->Geometry Tools->Polygons to Lines
-
Input layer:
Buffer
-
Click
Run
-
On the Layers Panel, Rename
Lines from Polygons
layer toclipping
-
Remove
Buffer
layer
- Go to
Raster->Extraction->Contour...
- Input:
Clipped (mask)
- Output:
~/terrain/contours.shp/
- Interval between contour lines:
304.8
(1000ft in meters) - Click
OK
Note: After it completes, click OK
on the popups and Close
on the Contour window.
-
Go to
Vector->Geometry Tools->Simplify geometries
-
Input layer:
contours
-
Tolerance:
0.002
-
Click
Run
-
On the Layers Panel, remove
contours
layer -
Rename
Simplified
layer tocontours
-
Go to
Vector->Data Management Tools->Merge Vector Layers
-
Layers to Merge:
perimeter
&contours
-
Click
Run
-
In the Processing Toolbox, seach for
Polygonize
tool -
Input:
Merged
-
Click
Run
-
Go to
Vector->Geoprocessing Tools->Clip
-
Input:
Polygons from Lines
-
Clip:
airspace
-
Click
Run
-
In the Layers Panel, Remove
Polygons from Lines
layer -
Go to
Vector->Geoprocessing tools->Eliminate Sliver Polygons
-
Input layer:
Clipped
-
Selection attribute:
area
(Note: May require changing input layer toairspace
and back toClipped
) -
Comparison:
<=
-
Value:
0.00005
-
Merge selection:
Largest common boundary
-
Click
Run
*Note: This step can sometimes take a while to complete.
-
Go to
Raster->Zonal statistics->Zonal statistics
-
Raster Layer:
Clipped (mask)
-
Polygon layer:
Cleaned
-
Statistics to calculate:
mean
-
Click
OK
-
In the Layers Panel, select
Cleaned
layer -
Go to
Layer->Toggle Editing
-
Go to
View->Select->Select by Expression...
-
Expression:
"mean" < 304.8
-
Click
Select
-
Click
Close
-
Go to
Edit->Delete selected
-
Open
Field Calculator
(Button with an Abacus at the top of the screen) -
Check
Create virtual field
-
Output field name:
elevation
-
Output field type:
Decimal number (real)
-
Expresion:
floor("mean" / 304.8) * 304.8
-
Click
OK
-
Go to
Layer->Save Layer Edits
-
Go to
Layer->Toggle Editing
-
Go to
Layer->Save As...
-
Format:
GeoJSON
-
File Name:
~/terrain/icao.geojson/
whereicao
is the ICAO code of your airport, e.g.KSEA.geojson
-
CRS:
EPSG:4326, WGS 84
-
Fields to export:
elevation
-
Coordinate precision:
10
-
Click
OK
-
Go to
Project->Save As...
-
Save as
~/terrain/icao.qgs/
whereicao
is the ICAO code of your airport, e.g.KSEA.qgs
-
Exit QGIS
-
Delete
DEM
folder from~/terrain/
-
Go to the Airport Modelling Repo
-
Click
Upload Files
-
Drag
~/terrain/
folder into the page. -
Add a simple commit title
-
Check
Commit directly to the master branch
-
Click
Commit changes
-
Copy the
~/terrain/icao.geojson
file into~/openscope/assets/airports/terrain/
-
In the airport file, ensure
has_terrain
is set totrue
If you've made it this far, you have successfully generated a terrain file for openScope. Give yourself a break now, you deserve it!
If you're having any problems while following this guide, you can talk to us on Slack, where we will be happy to help you!
Using QGIS 3.4 and above, there is now a plugin - qgsopenscope that:
- Loads the airport.json files
- Automates the terrain generation process described above
- Generates water polygons from the NOAA's Global Self-consistent, Hierarchical, High-resolution Geography Database (GSHHG) database.
Intructions on how to install and use the plugin are located in the repository, as well as some videos (no audio, but subtitled) on YouTube that demonstrate the usage:
- The qgsopenscope repository
- Video - Installing and using the QgsOpenScope plugin for QGIS
- Video - Reshaping water polygons to match the video map
- Video - Adding River Polygons to openScope terrain
The GSHHG database only contains coastlines and lakes. In order to generate river polygons, the lines can be imported from the CIA World DataBank II (Rivers and Political Boundaries). If you've already downloaded the shapefiles required by the qgsopenscope plugin, then you will have these files. Otherwise, downloaded the shapefile archive, and unpack it.
There are a few ways of loading the existing terrain:
- Generate the terrain using the qgsopenscope plugin This will generate the airspace an terrain for the current airport data.
- Open the QGIS project file from the airport-modeling repository If you do this, make sure that the project airspace matches the current airport data.
- Add the existing aiport.geoson file into a new QGIS project. You will also need to load the airspace to determine the bounds.
Note: Ensure the project CRS is WGS84
(EPSG: 4326
)
This is a relatively arbitrary process and you will have to decide which rivers to include. The CIA World DataBank II (WDBII) databases contains 11 levels of waterways. Levels 1, 2 and 3 should be sufficient. The levels we're mainly interested in are:
The "fine" data should be of a sufficient quality, so add the following layers into QGIS:
- WDBII_shp/f/WDBII_river_f_L01.shp - Double-lined rivers (river-lakes)
- WDBII_shp/f/WDBII_river_f_L02.shp - Permanent major rivers
- WDBII_shp/f/WDBII_river_f_L03.shp - Additional major rivers
- Also add the OpenStreetMap layer to the project, and use this to determine which rivers should be used. A rough rule is to include rivers at least 200m wide.
- Select the features that you want to use
- Paste the features as a new Temporary Scratch Layer (
Ctrl+Alt+V
) and call it "Rivers" - Hide all the "WDBII*" layers (we don't want to accidentally modify them)
- Toggle editing on the "Rivers" layer and select all the features.
- Select all the segments for each river, and use the
Merge Selected Features
tool. - Use the
Simplify Features
tool, set the tolerance to0.0005
and selectMap Units
. - Toggle editing and save any changes.
Open the Processing Toolbox
(Ctrl+Alt+T
), and then for each river:
- Select the feaures
- Open the
Measure Line
tool (Ctrl+Shift+M
) to measure the width agains the OpenStreeMap layer, using the units as degrees. - Open the
Vector Geometry -> Multi-ring Buffer
tool - Use "Rivers" as the
Input Layer
- Check the
Selected Features Only
box Number of Rings
should be 1.- Enter the measurement from Step # 1 into the
Distance between Rings
box. - And run.
- Copy all the new river polygons into the terrain or water layer.
- Toggle editing on the "Water" layer
- Select all the rivers, and use the
Modify Attributes
tool to ensure each polygon'selevation
attributes is0
- Save changes to the layer
- Use the
Merge Selected Features
tool to merge any water polygons that intersect. - Remove any extraneous nodes.
- Use the
Reshape Features
tool to remove any segments that are outside the airspace.