User Tools

Site Tools


arma3:terrain:road-shapefiles-real-world-data

This is an old revision of the document!


Road Shapefiles from Real World Data

How to use real world data road shapefiles from OpenStreetMap (OSM) in ArmA 3.

In this tutorial we download OSM shapefiles from the web, crop them to our terrain size and reproject them to match terrain builder UTM zone.

If not otherwise mentioned, global mapper is assumed.

OpenStreetMap Download

Geofabrik site has OpenStreetMap (OSM) shapefiles available for download.

Do not try to download “Asia” or “Africa” as those files are huge, click on Asia or africa instead and from there you can find individual country pages like iraq and afghanistan so your downloads are mere few megabytes instead of gigabytes (not to mention the unpacked data is insanely large).

OSM includes roads but also many other features, they even have buildings and vegetation areas. Although no idea how to use the building information with terrain builder or other tools.

OSM Road Shapefile Tutorial

OSM Roads Using Global Mapper and QGIS

Yes unfortunately at our current knowledge level we need BOTH of these softwares to achieve OSM roads in terrain builder. If you know how to do this alone in either software please contact us. :(

  1. download road shapefiles from geofabrik as SHP (shapefiles) files for your terrain country(s)
  2. unpack and move them to directory where you want to store OSM shapefiles, but do not put in your terrain builder project dir
  3. open your terrains global mapper project (UTM projected) and open your road shape file(s), hide other layers
  4. select digitizer tool (ALT-D) and select / hightlight user created feature grid
  5. RMB grid → crop/combine/split functions → crop loaded features to selected areas (or simply click crop to selected areas button, haha)
  6. setup dialog choose feature layer → user created features, click ok
  7. hide osm road shapefile layer, now you see road shapes inside your terrain user created feature grid, cool!
  8. file → export → export vector/lidar format, choose dropdown shapefile, click ok
  9. shapefile export options → export lines / select file → give filename click save
  10. enable “generate projection (prj) file for each exported shp file, untick rest, click ok

DOES NOT WORK!:

  1. file → unload all (CTRL-U)
  2. open data files → select the shp file you just exported
  3. RMB the only layer which is your cropped road shapefile → shift - shift selected layers a fixed distance
  4. choose dropdown shift layers a fixed distance, click ok
  5. specify offset dialog insert the X/longitude and Y/latitude values matching to your terrain coordinates (see below), click ok

What does not work? Well the coordinates jump to some crazy large number 3999999999999900 something like that, I have no idea why and what I do wrong in that part. Read below how to transform roads in QGIS instead.

QGIS Transform:

  1. open your heightmap in UTM 31N, this is just for visual reference. add raster layer → choose your asc file
  2. add vector layer → browse, choose your global mapper cropped and exported road shapefile, click open
  3. RMB roads layer → set layer CRS → choose WGS 84 / UTM zone 31N, click ok
  4. RMB roads layer → zoom to layer
  5. next we use stuff from QGIS Reproject & Transform Tutorial, CTRL-ALT-T to open processing toolbox
  6. type in v.transform and double click open the v.transform option
  7. input vector layer needs to be your cropped roads, X and Y shift needs to be your terrain coordinates calculation (see below)
  8. click run to execute, wait patiently it takes a while depending on your shapefile size
  9. select transformed layer, RMB → zoom to layer, now you see roads aligning perfectly with your heightmap, congrats!
  10. transformed layer RMB → save as → browse, this is your final road shape file name to be used in terrain builder, click ok

All done! :-)

Enjoy your real world data openstreetmap roads in terrain builder :-)

Shift Projection to Terrain Builder

In global mapper when you have chosen your terrain area by creating user created features grid, you need to export ASCII Grid ASC heightmap file to see the header for coordinates.

Use proper text editor to open this ASC file and check the header for xllcorner and yllcorner values. These values are used to calculate the terrain builder easting 200000 and northing 0 values.

Easting 200000 will be done by calculating 200000 - xllcorner value. And northing is dead simple, you just take yllcorner value as-is.

So now you have these two values, they can me inputted to QGIS to transform your project coordinates into those of arma3 terrain builder.

Here is example heightmap.asc header:

ncols         512
nrows         512
xllcorner     618849.895
yllcorner     3433172.322
cellsize      5

So you would take xllcorner and calculate that like this “200000 - 618849.895” equals to -418849.895 value. Then as terrain builder northing is just 0, we dont have to do any calculations we use it as is.

Result shift / transform would be:

X: -418849.895
Y: -3433172.322

Remove "Bad" Roads

OSM shapefiles come with all kinds of backyard “path” roads etc, you might want if not have to remove some of these.

OSM Road attribute types are described in openstreetmap map features: highway.

Use search → search by attributes. This search vector data dialog you can do all kinds of search & delete operations.

If you click to sort the FCLASS column, you can most likely see “unknown” and “unclassified” types, its up to you to decide which road types to remove (see the above OSM road attribute types list), as you really don't need all in arma3 terrain.

How to delete

Choose attribute/item dropdown for FCLASS, then type your search string to compare value field, then hit new search button.

Now you can click select all and delete selected buttons to delete all these search matches.

You can search more by just typing in new search string to compare value field and clicking new search button.

Once you're done with deleting “bad” roads, simply export your roads by file → export → export vector/lidar format, as usual.

Simplify Road Shapefiles

Most likely your OSM downloaded road shapefiles are too complex for terrain builder / arma3, so you need to simplify them. Meaning there are way too many vertices in the polylines which can be reduced.

If you import too complex or “large” road shapefiles to terrain builder it will start to stutter and freezes up.

In global mapper select all your road features, digitizer tool RMB → move / reshape features → simplify reduce vertices of selected line area features.

From enter simplification threshold dialog, use horizontal threshold 10 and vertical threshold elevation (meters) 0.2 for good results.

ID and ORDER

When you are using OSM road shapefiles there are lot of crap info attributes which are not used by terrain builder, you must delete these and replace with ID and ORDER attributes. If you try to bring OSM shapefiles as-is to arma3, it will crash.

Terrain Builder uses ID and ORDER values for road shapefile database. See further details from PMC Ultimate Terrain Tutorial: Roads - Export.

  1. select digitizer tool (ALT-D)
  2. select all features (there are many ways, for example drag a box around your roads, or RMB layer → select all features)
  3. RMB feature layer to bring up modify selected line features dialog
  4. feature attributes area click delete button, select attributes to delete dialog click check all, click ok (attributes are now deleted)
  5. back in modify selected line features dialog click new button, name ID, value 1, click ok. now ID attribute is set
  6. click new, name ORDER, value 0, click ok. now ORDER attribute is set
  7. modify selected line features dialog click ok
  8. ready to export your ID and ORDER attributes roads shape file

OSM vs SHP Files

by Bushlurker

The .shp and the .osm packages are “nominally” the same. the main visible difference being the shapefile downloads are individual “layers” and the ”.osm“ is “All-In-One”.

However, you'll sometimes find that the ”.osm“ version of an area has more detail than the equivalent shapefiles pack, or there's additional layers not included in the matching .shp pack. So it's always a good idea to grab both sets of data for any area you're seriously interested in, and check them both out thoroughly - cherrypick the best of the useable data from whichever seems best.

You'll find that the .osm's seem to consist of all the shapefiles muddled together on a single layer… However, all the individual shapes are carrying “metadata” - they have ID's, names, types, etc…

Most GIS programs, GM included, have a “metadata search” function which will allow you to search that whole jumbled layer of shapes and select only those labelled “residential road” for example, or “highway”… you can then select only that “class” of shape and isolate them from the rest by copying to a new layer…

Keep doing that and you can extract a whole bunch of useful layers from lakes & rivers, thru roads, vegetation areas, agricultural areas, etc, etc… with OSM it's all down to luck as far as coverage and quality is concerned, but most times you should be able to acquire some useable stuff, and save a considerable amount of time….

OSM Download Links

arma3/terrain/road-shapefiles-real-world-data.1486461149.txt.gz · Last modified: 2017-02-07 09:52 by snakeman