Creating shape files in QGIS for map data - dcs-liberation/dcs_liberation GitHub Wiki

Not finished, to be continued

This guide will enable you to create data that the developers can use to enable support for a new map. We will use QGIS, an open-source GIS program to generate this data from various open sources. You need to have QGIS installed, preferably a 3.x+ version with GRASS processing toolbox. https://www.qgis.org/en/site/forusers/download.html

Here is some basic information about what a .SHP shapefile is: https://en.wikipedia.org/wiki/Shapefile

The support of shapefiles is new for version 6.0 and enables you to use a dedicated GIS program to create data where the game should and should not allow frontline units and ships to be. QGIS is a very powerful program and you can arrive at the end product in a near infinite number of ways. In this guide one possible workflow is outlined that tries to take as many factors into account for problem free spawning. It will still be up to the campaign designer to use judgement where to place the frontlines to avoid troublesome behaviour.

Here are the basic steps you need to take

1) Map projection

Some basic concepts about map projections can be learned here: https://en.wikipedia.org/wiki/Map_projection

For DCS you need to know that the DCS maps use a UTM projection (meaning coordinates is measured in meters as opposed to degrees, basically), and we need to find out the UTM tile for the map we are working on. https://en.wikipedia.org/wiki/Universal_Transverse_Mercator_coordinate_system

1.1 Find the correct projection for the map

Through PyDCS we already have the center meridian of the map, meaning we can figure out the proper UTM projection (https://github.com/pydcs/dcs/blob/master/tools/export_map_projection.py).

CENTRAL_MERIDIANS = { "caucasus": 33, "falklands": -57, "nevada": -117, "normandy": -3, "persiangulf": 57, "thechannel": 3, "syria": 39, "marianaislands": 147, }

We can use this map to check out different UTM zones. By clicking on the UTM tile you see the central projection. The map central projection is not necessarily in the center of the map. In the case of South Atlantic it begun as only the Falklands islands so the projection for the whole map is UTM 21S (S for South hemisphere) FindProjection

1.2 Set up your QGIS project

Then it is a matter of making a new project in QGIS and setting the project CRS to be this. Projection

1.3 Visualizing your map by using tiles for satmaps or OpenStreetMaps live view

You can add XYZ tiles from this python script to add in a bunch of online satmap tile layers you can use: https://raw.githubusercontent.com/klakar/QGIS_resources/master/collections/Geosupportsystem/python/qgis_basemaps.py

2) Outlining the game area

In the correct projection you can now create a new vector polygon layer and add the game area as an overlay. Preferably by gettting actual coordinates from the ME as opposed to freehand editing like i did. Layer-> Create Later -> New shapefile layer ShapefileGameArea

Make sure you use the project CRS (projection) and that it is a polygon. Also make sure you save it to a location so you can retrieve it the next time you open the project. You can save the temporary layer by right clicking the feature in the layer view and select Save Feature As. This also handy to check during the save that the projection is what you expect it to be.

GameArea_makepoly

3) Oceans

3.1 Getting the source data and processing it

For the ocean I downloaded the OSM Ocean Polygon files (source https://osmdata.openstreetmap.de/data/water-polygons.html). These are WGS84-projected chunks of ocean. Select all the vector objects that are relevant to the map, and use the Vector->Geoprocessing->Dissolve command to merge the cells into one object. This will output a new temporary layer (can be slow to do). This layer we can now save and reproject it to the relevant UTM projection, like UTM 21S for the Falklands map. Right click on the temporary output layer and select Export -> Save Feature As... Be sure to reproject only after dissolve or you will potentially get gaps in the ocean file. image

Once you have the ocean file dissolved and projected to the correct UTM projection you can clip it to the game area overlay (Vector -> Geoprocessing -> Clip).

ClipSea

Once again this is saved as a temporary file which you now can save to disk.

3.2 Generating Liberation-usable land and sea data.

The final step is now to generate the land mass for Liberation as well as the actual ocean. Remember, we want to keep this data as lightweight as possible so we will first simplify the data. Use Vector->Geometry tools->Simplify and try different values

Simplify

A tolerance value of 250 is probably fine at this stage but you can go more aggressive if you want to. After we simplified the data now is the time to generate land data and ocean data. We will use the basic, simplified ocean to generate both the land and sea area. To make sure we get some margins so you cant accidentally move the carrier right to the beach or spawn units in the sea I want to use a buffer zone from the shore inland for the land map and a buffer zone from the shore out towards the sea. In the South Atlantic map I elected for a 750m buffer inland and a 1500m buffer out to sea. The 1500m buffer out to sea means a lot of the smaller sounds and bays will be eliminated, further simplifying our data.

Buffer

image

Here we can see our ocean that is buffered outwards from the shore 1500m

To actually get land area as opposed to a sea that reaches inland 750m we need to use the difference command (Vector -> Geoprocessing -> Difference) image

Make sure you have the Game area as input layer and the buffered sea as overlay.

You should now have something like this:

image

Congratulations, you now have the land and sea data!

4. Exclusion data

Naturally, not all of the landmass is suitable to have warring armies on them. We should at least make lakes and rivers off-limits, and big cities too. We need to get source data to work with, process this data to make it as light-weight as possible.

4.1 Downloading OSM vector source data

From the link below you can find collections of OSM source data that you can download and add to your QGIS project. https://download.geofabrik.de/index.html

The easiest way is to download the SHP files for individual countries. In this case I downloaded Argentina and Chile and added the layers I thought necessary to the map: water, waterways and landuse.

4.1.1 Processing the data

Once we have all the files, we need to do the following:

  • Resave the files in proper projection
  • Clip the files to only encompass the game area
  • Simplify the data
  • Buffer lakes and rivers slightly

This can be done using the same techniques we learned in section 3.

4.2 Downloading DEM data for slope analysis.

This step is potentially optional, but if the map contains many mountains and steep terrain like the South Atlantic map does it can be worthwhile to do.

https://search.earthdata.nasa.gov/search/granules?p=C1546314043-LPDAAC_ECS&pg[0][v]=f&pg[0][gsk]=-start_date&q=nasadem&sb[0]=-71.22656%2C-51.47764%2C-68.23828%2C-49.30728&tl=1662388101!3!!&lat=-50.901136037047934&long=-73.1337890625&zoom=6

We will NASAs EarthDataSearch portal to find DEM data. I have used the NASADEM Merged DEM Global 1 arc second V001 dataset since it is reasonably high-resolution and free to use. You will need to register for the service, log-in, search the site for the correct dataset, and then draw an outline of the area you want to create a download link.

image

4.2.1 Processing the DEM files.

To make editing easier, you will want to merge all your cells into one file using Raster->Miscellaneous->Merge. It can still be useful to retain one or two cells for testing commands on a smaller dataset so you are sure you get what you want.

Now that we have the DEM file, we need to visualize the data. At this point, you should probably have an instance of DCS open so you can cross-reference the ingame view to better judge what slopes are fine and what are excessive.

We will use the Raster -> Analysis -> Slope tool to make a slope map

image

The slope mape can be visualized by right clicking on the layer and selecting properties, and selecting the Symbology tab. Here we will select "Singleband Pseudocolor" and play around with the values to find what slope value should be the cutoff, values above which are considered impassable.

image

image

By zooming out and changing color palettes and values of various colors you can probably find a value that seems reasonable. In the image above the red-value areas are probably bad for ground units while the other colors are passable.