Preparing FKB data

From Maria GDK Wiki
Jump to navigation Jump to search
FKB data in Maria GDK, looking sharp.

FKB (Felles KartdataBase) consists of the most detailed vector data from Kartverket. There are a number of different map themes, but these themes are not neccesarily the same from year to year. Sometimes map themes are taken out from the official FKB definition and offered separately. Finding out where to get them can require take some detective work, but Geonorge is a good starting point. For simplicity, in this guide we will refer to all the data we use as FKB.

The file type is, for most of the themes, SOSI. FKB data is also offered in other formats, but using those requires adjusting the toolchain so that layer and attribute names fit with the existing styling.

The Maria GDK products which contain this data and the associated styling are called NorwayTopoDetail. There is one product for each fylke.


Prerequisites

The toolchain to convert FKB data to Vector Tiles requires a number of FME workspaces, Powershell scripts and executables:

Name Type
GeoSOSI Professional FME plugin from Geodata
sosi2m6mformat_FKB_geotype_layernames.fmw FME workspace
workspacerunner.fmw FME workspace
sosi2m6mformat_hoydekurver_5m.fmw FME workspace
sosi2m6mformat_FKB_Matrikkelkart.fmw FME workspace
filegdb2m6mformat_FKB_Tekst5000.fmw FME workspace
tovectortileset.exe Executable
Invoke-Parallel.ps1 Powershell script
buildvectortiles_FKB_parallel.ps1 Powershell script
buildvectortiles_FKB_merge.ps1 Powershell script
gml2mbtiles_Elveg2.0.fmw FME workspace
gml2mbtiles_matrikkel-vegadresse.fmw FME workspace
buildvectortiles_fylkefolders.ps1 Powershell script

Base data

The Base data consists of several map themes which are ultimately merged into one Vector Tiles file for each fylke. In 2020 it consisted of:

  • Main delivery:
    • AR5
    • Arealbruk
    • Bane
    • BygnAnlegg
    • Bygning
    • Ledning
    • LedningVA
    • Lufthavn
    • Naturinfo
    • Servitutt
    • Tiltak
    • TraktorvegSti
    • Vann
    • Veg
  • N5 Høydekurve 5m (Contour lines)
  • Eiendomsgrenser (Real estate boundaries)
  • N5 Presentasjonsdata (Place names)

Main delivery

The FKB main delivery consists of several map themes per kommune.

Each file contains of several feature types/layers. For instance, the layers Trafikkoy and Vegbom both come from the Veg SOSI file. All SOSI files should be unzipped and/or moved into the same folder.

The base data is converted from SOSI to m6m using FME. The main workspace is sosi2m6mformat_FKB_geotype_layernames.fmw. This workspace uses the kommune-number as a fanout attribute. The kommune-number is read from the filename (the attribute fme_basename) using a SubstringExtractor transformer. The filename structure might change from year to year, so make sure that the SubstringExtractor reads the correct characters.

Specify the indexes of the kommune-number in the filename

The sosi2m6mformat_FKB_geotype_layernames.fmw workspace is run in parallel using another workspace, workspacerunner.fmw In workspacerunner.fmw, set the Folder and File Pathnames reader to read all your unzipped SOSI files. The WorkspaceRunner transformer should point to sosi2m6mformat_FKB_geotype_layernames.fmw. The rest of the parameters should look something like this:

Log File can be left blank, but logging is useful to uncover problems

The result should be a large number of m6m files, split into one folder for each kommune. There are a few more themes which needs to converted into the same kommune-folders. In the last steps, they will all be merged together into the same Vector Tiles datasets.

Høydekurve (Contour lines)

We use countour lines with 5 meter contour intervals. Use the workspace sosi2m6mformat_hoydekurver_5m.fmw. You can run this workspace directly, or you can run it in parallel through a WorkspaceRunner for more efficiency. You should end up with a Hoydekurve.m6m file in each of your kommune-folders.

Teiggrense (Real estate boundaries)

Vector lines describing real estate boundaries. The dataset from Kartverket is called Matrikkelen - Eiendomskart. Unzipped, you should have a folder with one SOSI file for each kommune. Use the workspace sosi2m6mformat_FKB_Matrikkelkart.fmw in the same way as the previous datasets. You should end up with Teiggrense_line.m6m in each kommune-folder.

N5 Presentasjonsdata (Place names)

Points used for place name labels. In 2018, this dataset was in File Geodatabase format. The workspace used was filegdb2m6mformat_FKB_Tekst5000.fmw. Because the source is a single file, this workspace cannot be run in parallel with a WorkspaceRunner. The result should be presstedsnavn_point.m6m in each kommune-folder.

Converting from m6m to Vector Tiles

You should now have the base data, in addition to Høydekurve, Teiggrense, and N5 Presentasjonsdata, as m6m files split by kommune.

The next step is done using Powershell scripts and tovectortileset.exe. The first script to run is buildvectortiles_FKB_parallel.ps1. You should enter values for the variables

  • $src - folder containing all the m6m kommune-subfolders
  • $trgt - output folder
  • $threads - number of parallel processes.

and also the path to the parallelization script Invoke-Parallel.ps1.

This script should result in a large number of .vtiles.sqlite files, two for each kommune.

Finally, we will merge the files so that there is one file per fylke. This is done with the script buildvectortiles_FKB_merge.ps1. You should enter values for the variables

  • $src - folder containing all the kommune vtiles-files
  • $trgt - output folder
  • $threads - number of parallel processes.

and also the path to the parallelization script Invoke-Parallel.ps1. In addition, check that the variable $fylker holds a list of the current fylke-numbers in Norway. This script should result in one .vtiles.sqlite file for each fylke.

Finally, it's a good idea to run extractmapinfo_parallel.ps1 on the final result to generate reports on each file. These files help to identify any problems.

Both .vtiles.sqlite files and and the reports can finally replace the existing files in the NorwayTopoDetail map products.

Elveg

Elveg is a dataset representing the road network in Norway. In NorwayTopoDetail we use the road center lines to label road names and numbers. The Vbase line features themselves are not visible in the map.

We create Elveg as a separate MBTiles dataset from the base data. However, it is split by fylke in the same way.

Our starting point is one zipped Elveg GML file for each fylke. We use the FME workspace gml2mbtiles_Elveg2.0.fmw.

After running the workspace, you should have one MBTiles file for each fylke, which replaces the MBTiles files in the existing NorwayTopoDetail products.

Matrikkelen - Adresse (Adress labels)

Points representing street adresses. It is placed in each NorwayTopoDetail as a separate dataset in the same way as Vbase

The starting point should be one zipped GML file for each fylke. Use the FME workspace gml2mbtiles_matrikkel-vegadresse.fmw. After running the workspace, you should have one MBTiles file for each fylke, which replaces the MBTiles files in the existing NorwayTopoDetail products.