QGIS Roads and Smoothing

Discussion in 'World Editor' started by el_ferrito, Jan 19, 2022.

  1. el_ferrito

    el_ferrito
    Expand Collapse

    Joined:
    Sep 30, 2020
    Messages:
    414
    Ok... Another go at this post.

    I am trying to use LIDAR data, QGIS and GIMP and Excel to automate as much of the map making process as possible.

    At some point I will explain what I've done in detail, but to cut a long story short, the following images were all from maps created without any manual input from me in the world editor (all done through the four programmes mentioned above). Total time from download to the map below was around 30 mins - with quite a lot of mistakes on my part, I reckon I could get it down to 10 minutes.

    Steps (short version):

    - QGIS provides the relevant google maps image, as well as the road placement data (from Open Street Map)

    upload_2022-1-19_10-59-36.png

    - I export the road position data into excel to covert it into the item.level.json format (just overwrite the file in the level road folder in my case)

    - I also output the road data as an image, to use as a terrain mask, but also for smoothing
    upload_2022-1-19_11-2-56.png

    - I use GIMP to smooth the heightmap (from the LIDAR DTM), only where the roads are, so the rest of the map keeps the rougher LIDAR features.

    upload_2022-1-19_11-5-18.png upload_2022-1-19_11-10-14.png
    - In the world editor, I then use Terrain import to set the terrain (heightmap) and the placement of terrain types (binary white/black maps: grass, forest, asphalt, etc).

    This includes the pre-smoothed roads (e.g. below is an example from another map):
    upload_2022-1-19_11-1-35.png

    But also with the road decals placed already.

    "Final" first draft map with no manual smoothing/decal placements:
    (note some strange artefacts, often where the road decal doesn't display properly- these are mostly where the QGIS data has two vertices really close together, which causes the decal smoothing algorithm to go bananas. I think I have a solution to try out for a future effort).

    screenshot_2022-01-21_14-22-50.png

    screenshot_2022-01-21_14-22-07.png

    screenshot_2022-01-21_14-21-50.png

    screenshot_2022-01-21_14-21-11.png

    Here is a video to give an idea of how smooth the auto-smoothing using GIMP is:



    Future plans:

    - I have a bit more sorting to do with the roads to try to automatically smooth them.
    - I will likely add a similar approach to add forest items (randomly placed within the forest terrain areas), this might take a little while.
    - I like the google maps image when it is countryside, but it isn't always idea, so I might include an L3DT generated level texture in the final process too, this should give a terrain that looks more like those of the BeamNG vanilla maps (although not quite as detailed).
     

    Attached Files:

    • upload_2022-1-19_10-58-58.png
    • upload_2022-1-19_11-2-34.png
    • upload_2022-1-19_11-4-55.png
    • upload_2022-1-19_11-5-35.png
    • upload_2022-1-19_11-14-9.png
    #1 el_ferrito, Jan 19, 2022
    Last edited: Jan 21, 2022
    • Like Like x 10
  2. Djungle

    Djungle
    Expand Collapse

    Joined:
    Aug 27, 2022
    Messages:
    1
    Hello el_ferrito,thanks for your post.

    With QGIS I have exported height maps from Geotiff elevation data using the plugin Heightmap Export, from the QGIS Plugins Manager ,and also satellite imagery of the same area exporting map to image using the extracted extent of the elevation raster data as the extent of the image. All is working in BeamNG.

    I have road line data, and I am hoping you would explain in detail, on how you got the road position data into BeamNG.
     
  3. el_ferrito

    el_ferrito
    Expand Collapse

    Joined:
    Sep 30, 2020
    Messages:
    414
    The short answer is:

    Export the road line data from qgis to CSV (X,y,z format)

    Then lay a couple of decal roads in your map to generate the .json file.

    Use Excel to make a version of the JSON with your data in (this is tricky). Remember to normalise your coordinates to the max and min xy coordinates of your terrain.

    Then load it in.

    FYI it will crash of there are too many roads or the road length is too long in total. Not sure what the upper limit is.

    For the smoothing, take the road vectors in qgis and convert to thick lines. Export these as an image. Use the image in gimp or Photoshop to select the equivalent area on the heightmap. Copy and paste the road only heightmap data to a new layer.
    Before anchoring (important), run a smoothing function like Gaussian, or multiple direction blurs, then anchor and merge the layers to get the final heightmap.

    I usually then do another selection of the road area, grow it by a pixel or two, and then do a low level Gaussian blur, to smooth up the road edges a bit.

    Apologies I can't provide more detail right now.
     
  4. AlexKidd71

    AlexKidd71
    Expand Collapse

    Joined:
    Mar 16, 2022
    Messages:
    331
    What a great idea! I did that stuff with the blender osm gis plug-in and generated the heightmap in blender which was no joy. But at least you get the road data as single layers. And that divided by road categories farming, dirt, national roads and so on. Very good for the right ground model. But generating the decals is really cool! Perhaps we can build a small tool instead of excel. I’m a developer.
    Best! Alex.
     
  5. el_ferrito

    el_ferrito
    Expand Collapse

    Joined:
    Sep 30, 2020
    Messages:
    414
    I'm completely not a developer, but I like the idea of a tool if you think you can do it. I have a few other things I've been looking at with Blender, QGIS and BeamNG too, but mostly I get to a certain point and either it works enough for me, or I have no idea how to take it any further.

    I did a map of london with the OSM plugin, it was a proper mess.. haha.

    Alongside the QGIS approach, I think a tool that would be really useful would be just a standard vector paths (from say GIMP) to smooth a heightmap, and then apply different road decals (if that makes sense). That way you could use any old heightmap, just quickly sketch which roads you wanted and where, and bosh, it's all done. But it is beyond me.
     
    • Like Like x 1
  6. RiChuF

    RiChuF
    Expand Collapse

    Joined:
    Jan 21, 2022
    Messages:
    71
    and heres me spending hours doing it all manualy like an idiot :(
    thanks for the tips :)
     
    • Like Like x 1
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice