10 – How to create a vector map for your building

Introduction #

In the following how to guide, we will explain how to create your custom vector map. The starting point will be any source of cartography (ideally AutoCAD files, such as DXF or DWG) and result into a working vector map uploaded and published on Situm platform.

For this guide we will assume you have:

  • A building on the Situm Dashboard and some experience managing Situm cartography.
    • At least you will need to have uploaded some image floorplans. It
  • Source floorplans of the building (ideally CAD files).
  • Some experience with AutoCAD and a working AutoCAD installation.
  • QGIS installed. Optional plugin, Quick Map Service.

Drawing the floorplan in AutoCAD to generate a DXF file #

Usually you will need to redraw/simplify your CAD file following the guidelines we are explaining below.

You may use your AutoCAD files as a base or you can import your image floorplan into AutoCAD to use as a template on your drawing.

Using AutoCAD we will draw all the floorplans. We need to draw all the lines/polygons of a floor in a separate layer.

Guidelines for drawing:

  • Start a new layer for each floor of the floorplan.
  • Use only polylines to draw (you may also use lines, but is less recommended).
  • Draw only elements you want to appear on the map.
  • Make sure lines that should create a closed polygons are completely closed, overlap sides

Here you have an example map during the drawing process:

Once you finish, you may copy and paste the new layer into a new file, reference it to the ‘0,0’, and save this file in the DXF format.

Converting to GeoJSON with QGIS #

Once the DXF file with all the polylines representing the floorplan are drawn, a process to convert into standard cartographic format is needed. For this purpose we are going to use QGIS. The general process composes of the following steps, which we are going to explain in detail later.

  1. Import from DXF and georefence.
  2. Split each floor into a different QGIS layer.
  3. Polygonize
  4. Save as GeoJSON.

Import DXF and Georeference #

The first step once you have your DXF file is to import it into the QGIS app, for that, there are several ways to do it. We recommend the following method.

  1. Open QGIS and create a new empty project.

2. On the “Layer” Menu option, select “Georeferencer….”

3. This will open a new window with the Georeferencer tool.

4. Drag and drop your DXF file into the new opened window: you should see your drawing on top of the Georeferencer tool

5. Georeference at pleased three or four GCPs. You should have at least 3-4 GCP.

  • Tip 1: Use the Quick Map Service to overlay a satellite basemap overlay in order to create the Ground Control Points (GPC).
  • Tip 2: There are several transformation types on the georeference process, in our experience Polynomial 1 is the best for this task.

Remember to save the points after the georefencing process, it may be useful in case you need to redraw something on the CAD and re-georeference later.

6. Execute the georeference process and add the result to QGIS.

After clicking on execute (Green arrow button), you will get the georeferenced result on the main QGIS window.

At this point, you already have the drawed lines in a standard GeoJSON format. Now we are going to convert them into usable polygons.

Split each floor a different QGIS layer #

Now that you have all the lines into a single layer of QGIS, we need to split each floor into a different layer so we can continue the process with each layer individually.

Fortunately QGIS has a built-in algorithm to perform this task. The algorithm is called “Split vector layer”, you may access it in the “Processing Toolbox” (usually on the right).

This algorithm requires to indicate four important parameters:

  1. The input layer, which will be the recently georeferenced layer (obtained from previous step).
  2. The field to split by. In our case, the field “Layer” should be available on the DXF file we imported (assuming you’ve drawn each floor in a separate layer, as explained before)..
  3. The output folder on your computer.
  4. Format of the output files: GeoJSON.

Example of split layer execution:

At the end of this step you will have one standard GeoJSON file for each floor in your building. Now, we are going to polygonize the file and you will be almost there.

Polygonize #

All the steps that are shown from now on have to be replicated for each floor: we will also added an advanced section at the end on how to automate the process using QGIS Models.

First, we will generate polygons (polygonize) from the previous GeoJSON file. This is probably the most critical and delicate step of the process so we need to be extra careful. The QGIS Polygonize tool requires that on the input drawing all the polygons are correctly closed, in other case some polygons may be lost in this step. Since this process is so sensitive, we are going to perform a previous step (snapping).

Well closed polygon (left) vs non-closed polygon (right)

Snap geometry to layer. Even when the lines are so close that seem closed polygons to the naked eye, sometimes there are near vertexes that are not perfectly touching. The Snap geometries to layer will help you do that (make sure to have a copy of the file saved):


This step requires to indicate several parameters:
1 – Input and Reference Layer. Use the same layer in both fields.

2 – Tolerance. Make sure to add small tolerances to avoid snap distant vertexes. We usually use 10-20 cm for high def maps. 30-40 cm for mockups maps with little detail. If you are using a Coordinate System in degrees (e.g. WGS84 – EPSG:4326) instead of meters use ~0.000001 degrees of tolerance.

All other parameters should not be changed.

Example execution of a snap geometry:

Polygonize. Use the polygonize tool of QGIS, directly from the Vector geometry section on the Processing Toolbox. Remember you need to polygonize each floor separately.

The Polygonize Toolbox only needs the input layer as parameter. Example:


After the polygonization process you should be able to see the polygonization report:


Make sure that the NUM_POLYGONS is not 0. In your main QGIS View now you should be able to see the polygonized floorplan, example:

If the polygons are complete and correct, you already made the most difficult part of the map creation process. Don’t panic if something is missing, it is pretty common that some lines are not correctly overlapped and some of them should be corrected in AutoCAD and repeat the process. We will explain at the end of the guide, in an advanced section, how to automate some of the steps to go have faster, draw-polygonize cycles.

Save the result of the polygonization #

Now that you have the polygons, you have to save it in a suitable form that can be uploaded to the Situm Dashboard.

First, you should reproject the layer to WGS84 – EPSG:4326. In the Vector general section of the Processing Toolbox, we have the “Reproject Layer” tool.

Make sure to reproject all floors in the building, one by one. Example execution for one floor:

Once we are sure we have the correct projection set in the layer, we can directly save as a GeoJSON file for each floor using the “Export” (right click on the layer) > Save Features As…

After clicking on the Save option, a new menu will appear, where you have to indicate the folder and file name where to store. Example:

Congratulations!, you have converted your cartography (Image or CAD into usable and standard cartography format). Let’s use it on the Situm platform, so we can add some 3D, colors and publish it to the world.

Uploading your maps to Situm #

Now that you have your cartography converted to GeoJSON polygons, you can start using the recently created cartography on a Situm Viewer and style it. In order to get it finished and published we are going to follow the next steps:

First, in your Situm Dashboard account, open your building in the Situm Map Viewer from the left menu:

Then, enter “CTRL”+”.” and you should see this menu coming up. Select the GeoJSON editor:

Load all floors on the GeoJSON editor. To do that, select the floor one by one:

And upload the GeoJSON/IMDF file of each floor, one by one:

Then, export the whole GeoJSON/IMDF file:

Finally, upload your maps from Situm Dashboard. To do that, go to your building, click on “Edit Building”:

And use the cartography uploader (Vector Maps):

Styling your maps #

At this point, if you go to the Map Viewer, you should see your GeoJSON file overlayed on top of it. Now you may want to style it. Press “CTRL” and “.” simultaneously and go to the GeoJSON editor as shown before. To categorize each individual feature, select it and update the ‘Category’ field for each feature listed at the bottom

Then, select the “GeoJSON” theme from the menu.

And modify the properties of each category, such as the color or the height of the polygon. You should see that all the polygons of a certain category change their style accordingly.

Finally, download the theme file and send it to support@situm.com. We will apply it to your venue so you can see the result. Dot in the near future, you will be able to do this all by yourself.

Subscribe to our newsletter

BASIC INFORMATION ON DATA PROTECTION

Data controller: SITUM TECHNOLOGIES, S.L.
Contact: Data controller: situm@situm.es
Responsible for protection: dpo@situm.es
Purpose and legal basis: To manage the sending of SITUM newsletters only with consent.
Legitimation: Express consent of the interested party.
Recipients: The data will not be passed on to third parties with the exception of legal obligations.
Retention period: As long as the interested party remains subscribed to the newsletter (a link to unsubscribe will be available in each newsletter sent by Situm).
Rights: The interested party may at any time revoke their consent, as well as exercise their rights of opposition, access, conservation, rectification, limitation, deletion of data and not be subject to a decision based only on automated data processing, by writing to SITUM at the addresses indicated.
Additional Information: You can consult additional and detailed information on Data Protection in our privacy policy.

Please, download your copy here

Thank you for downloading our whitepaper. Please do not hesitate to contact us if you would like to know more about how our solutions can help your business. Download whitepaper


Close window