Lidar data tools for RTB

RaceTrackBuilder is limited to using terrain data provided by Google, but this data is rather coarse so it takes a lot of manual modelling and finetuning to make both road and adjacent terrain not looking a bit weird and synthetic. Now there’s options to get detailed terrain data into RTB:

  1. Obtaining and preparing the data
  2. Importing track elevation data
  3. Substituting Google terrain data <WIP>
  4. Creating 3D terrain chunks <WIP>

1. Obtaining and preparing the data

Find high quality terrain data of your area of interest. If the data is already in .copc.laz format and properly classified (ground-vegetation-buildings etc) the tiles can be directly processed. Some more info on preparing and merging lidar data can be found here. If you have the data in .las or .laz format, simply dragging the file(s) into QGIS will convert them into .copc.laz format. The reason for using this format is working with the files uses very little resources – unlike las/laz files which have to be loaded entirely into computer memory just for reading a single point.

To use the data for “Google terrain substitution” or “3D chunk creation” it has to be converted into a Geotiff DEM. A PDAL pipeline can be found here or the DEM can be made in QGIS; for larger/hi-res maps it’s important to set internal tiling (blocksize for instance 1024×1024) – otherwise performance will suffer.

2. Importing track elevation data

Create a GPX track of the route, make it 50-100m longer than the stage start/stop positions. gpx.studio is a great tool for creating GPX tracks. Start with the normal basemap and create the track by clicking a few points along the route with ‘follow roads’ enabled. Now switch to Mapbox Satellite using the layers icon.

Disable the “follow roads” toggle and make the GPX nicely follow the middle of the road. When ready, export the GPX and give it a meaningful name. Put it together with your lidar file into some working folder (let’s say c:\elevation-data). If the lidar files are not merged, put them in a subfolder (let say c:\elevation-data\tiles). Whether merged or not: files must be in .copc.laz format!

Now we need to setup a Python environment. Download and install the latest Miniconda, a lightweight Python installation. Keep default values during installation. In the start menu, find “Anaconda Prompt (miniconda3). A command line interface will open. Go to your working folder (cd c:\elevation-data). Now copy-paste following command to install required python libraries:

conda install conda-forge::pdal gpxpy geopandas shapely numpy pandas pyproj matplotlib

Download and extract the points extraction script into this folder. Edit the .ini file using notepad(++) and set the right filenames and parameters – do pay attention to coordinate system/EPSG code! All settings are explained in the .ini comments. Save the .ini file and launch the script by copy-pasting this command:

python GPX-to-points-string-with-elevations

If all goes well 3 files will be created:

  • A .csv file containing coordinate points & elevation data
  • A height profile: check if it looks smooth, if not there’s probably an issue with classification
  • A .gpkg file – draw this one into QGIS in case of problems, to check points spacing & location

Now the .csv file can be imported into your RTB project: Select File – Import Track

All set! Your feedback would be appreciated.

3. Substituting Google terrain data <WIP>

The Wurstkoffer-Neilson method works as follows:

  1. Redirect RTB terrain elevation queries to a local webservice instead of Google Maps by manipulating local DNS configuration.
  2. Scripts on this webservice further redirect the queries to a local (or online) data source, then translate responses into the Google format expected by RTB
  3. Using a local installation of GeoServer we can provide high-resolution elevation data.

REQUIREMENTS

  • Quality terrain data of the area of interest in the form of a Geotiff DEM – aim for 1 or 2m resolution, or better. See the first section above for preparing the Geotiff from lidar data.
  • QGIS as it contains a number of tools needed for preparing the terrain data
  • Download latest XAMPP
  • Download latest stable Geoserver
  • Download Java runtime: select the v11 LTS .zip version. Other Java runtimes can result in strange errors!
  • Geoserver configuration files (edited from Wurstkoffer)
  • (some scripts)

XAMPP INSTALLATION

GEOSERVER INSTALLATION