Skip to content

BAG20 Xml2MMD

MaartenHilferink edited this page Sep 11, 2026 · 1 revision

The BAG 2.0 can be downloaded (monthly update) from the Kadaster BAG 2.0 download page.

The download consists of a zip file with more than 3.000 xml files. Xml files are used as exchange formats but less suitable for processing.

Therefore the BAG20_Xml2MMD tool is used to convert these xml files to MMD stores, the GeoDMS native primary data format and the successor to FSS. Until 2026 the tool was called BAG20_Xml2FSS, after the format it wrote then. Geometry is stored in RD metres, as dpoint.

MMD data structure

The BAG is a historical database with one or multiple mutations (voorkomens) per object. The BAG20 Xml2MMD tool stores this historical information in a MMD store per BAG object type. Pand and verblijfsobject are delivered by the Kadaster in many xml files and are stored per file set, as a folder of stores:

%SourceDataDir%/BAG/date/mmd/
    ligplaats.mmd
    standplaats.mmd
    nummeraanduiding.mmd
    openbareruimte.mmd
    woonplaats.mmd
    pand/nr_stores.csv        the number of file sets
    pand/fs_1.mmd ... fs_N.mmd
    vbo/nr_stores.csv
    vbo/fs_1.mmd ... fs_N.mmd
    overzicht.txt

Every store is a folder with the data files and a 0Dictionary.dms that describes them: the attributes, their value types and the row counts. A reader therefore declares nothing; it opens the store with an empty holder and the dictionary supplies the items. The one thing the dictionary refers to outside the store is the coordinate unit, by its absolute path /geometries/rdc, so a project that reads these stores declares that unit under that name:

container geometries
{
	unit<dpoint> rdc : SpatialReference = "EPSG:28992";
}

unit<uint32> pand : StorageName = "%SourceDataDir%/BAG/20260108/mmd/pand/fs_1.mmd", StorageReadOnly = "True"
{
}

The data structure used is similar to the BAG, with one major exception. As the number of gebruiksdoelen of a VBO in the BAG is limited, the relation between VBO and gebruiksdoel is implemented as a set of boolean attributes for each VBO indicating if this VBO has this gebruiksdoel or not. This makes it easier to work with the gebruiksdoelen. The same data structure is also used in the BAG20 MakeSnapshot.

Each object type carries its generic BAG attributes in a meta container: STATUS, VOORKOMENIDENTIFICATIE, BEGINDATUM, EINDDATUM, TIJDSTIPREGISTRATIE, EINDREGISTRATIE, DOCUMENTDATUM, DOCUMENTNUMMER and IS_GECONSTATEERD. The one-to-many relations of a verblijfsobject, nevenadres and gerelateerdPand, are stored as sub tables with a mutatie_rel back to the row of the verblijfsobject in the same file set.

how to use this script

  1. Download the .zip from https://www.kadaster.nl/-/kosteloze-download-bag-2.0-extract. Extract the zip file to zip files for each BAG object type. DO ONLY EXTRACT THE LIG, NUM, OPR, PND, STA, VBO, WPL ZIP FILES !
  2. Extract the xml files from the zip files per BAG object type to a local folder, with naming convention: %SourceDataDir%/BAG/date/NGR:
    • The %SourceDataDir% is a placeholder for the SourceData folder on your local disk. By default the path: C:/SourceData is used. You can choose another path for your SourceData, but then you have to configure this new path in the GeoDMS GUI, menu option: Tools > Options > Advanced Tab > SourceDataDir control.
    • Use for the date placeholder the date of your download with as format: yyyymmdd.
    • The subfoldername NGR stands for: Nationaal GeoRegister.
  3. Make sure all zip files are extracted (your NGR subfolder needs to have more than 3.000 xml files).
  4. Open the BAG20_Xml2MMD.dms file from the BAG Toolkit scripts (in the cfg subfolder of your chosen project folder) in a text editor, configure the date of your download for the parameter date (yyyymmdd) and save your file:
// te configureren
parameter<string> date     := '20260108';
//
  1. Run the conversion, in one of two ways:
    • Open the BAG20_Xml2MMD.dms in the GeoDMS GUI and update the item: MaakMMDBestanden, e.g. by double clicking on this item in the TreeView. This can take some time.
    • Or run bat\RunXml2MMD.bat from the command line. It runs the whole conversion in one GeoDmsRun process under a memory budget, MEM_BUDGET_MB=8000 by default (GeoDmsRun's /SB<MB>): GeoDMS 20.20.0 processes the file sets of an object type side by side up to that budget and releases the memory of each file set once its store is written. The environment variable GEODMS_DIR names the folder with GeoDmsRun.exe (default C:\Program Files\ObjectVision\GeoDms20.20.0.m); XML2MMD_CFG and XML2MMD_LOG name the configuration and the log. PER_FILESET=1 keeps the earlier mode of one process per file set, for a hard bound of one file set in memory.
  2. The resulting MMD stores are written to your %SourceDataDir%/BAG/date/mmd folder, in the layout shown above.

Measured on the pand extract of 2026-08-08 (12.2 GB of XML, 50 file sets) on a machine with 32 threads: 132 s at a budget of 8000 MB, against 310 s file set by file set. The peak memory runs about 2.5 times the budget, because the budget estimates the work in flight rather than measuring it; a lower budget is not necessarily slower, since many parses running at once hinder each other.

polygon engine (GEO_ENGINE)

The pand geometries are dissolved per pand with a polygon union. Which family of polygon operators does that is set by GEO_ENGINE, a ConfigSettings/Overridable setting of the configuration:

  • geos (default): the geos_ operators, which need valid polygons and repair them first;
  • dms (GeoDMS 20.20.0 or later): the dms_ operators, GeoDMS's own sweep, which read every ring under the even-odd rule and so need no repair of rings stored the wrong way round.

Like every overridable setting it is given on the command line through an environment variable, GEODMS_Overridable_GEO_ENGINE=dms, or in the GeoDMS GUI under Tools > Options. The batch file takes it as an argument: RunXml2MMD.bat GEO_ENGINE=dms. Both engines write the same stores (identificaties identical, areas within 1e-6 relative); measured on the same extract, dms took 137 s against 132 s for geos at 8000 MB.

requirements/licensing/download

  • The configuration requires GeoDMS 20.20.0 or later: its root container carries the IntegrityCheck GeoDMSVersion() >= 20.20, so an older GeoDMS refuses it before anything is read.
  • See BAG Toolkit for the other requirements.

troubleshooting

If updating item: MaakMMDBestanden results in an error, check:

  1. if you have unzipped the earlier mentioned zip files, your NGR subfolder should contain more than 3.000 xml files.
  2. if your %SourceDataDir% placeholder refers to the actual physical path containing the subfolder (BAG/date/NGR) with the xml files. If this is not the case, configure the path for your %SourceDataDir% in the GeoDMS GUI: menu option: Tools > Options > Advanced Tab > SourceDataDir control.

Ignore the error(s) and reload the configuration file.

result

The result of this script is a collection of MMD stores for each BAG object type, which can be used to make snapshots from the BAG. Use the BAG20 MakeSnapshot tool for this purpose. The GeoCode tool reads these stores directly, as it selects its own reference date.

In the resulting mmd folder also meta information is stored in a file called: overzicht.txt. This file describes the number of xml files processed and the number of objects for each BAG object type. The information can be used as an indicator to check if all data is used in the MMD stores.

Clone this wiki locally