-
Notifications
You must be signed in to change notification settings - Fork 0
How to use the geocode script
This page describes how to use the Geocode.dms script to geocode addresses.
-
Make sure you generated and adres.fss subfolder with the BAG20 MakeSnapshot script.
-
Configure the snapshot date. Open the BAG.dms script file (in the cfg/Geocode subfolder of the download in a text editor. Adjust the configuration of the item: BAG/impl/SnapshotDir
parameter<string> SnapshotDir := '%SourceDataDir%/BAG20/snapshots.ext/20220701';
with the you date made the snapshot for with the MakeSnapshot tool of, using the format yyyymmdd.
- Configure the source file with the addresses to be geocoded. Open the bron.dms file (in the cfg/Geocode subfolder of your download) in a text editor. Configure the item bron/BestandsNaam:
parameter<string> BestandsNaam := '%SourceDataDir%/adres/to_be_geocoded.csv';
to the path and filename of your source file to be geocoded.
The source file needs to be a .csv text file with a header describing the address fields (see 4). The default expected delimiter for the csv file is the semicolon (;) , a comma(,) can also be used, in that case configure ';' for the item: bron/TableChopper/VeldScheidingsTeken. in the same bron.dms file.
- Adjust the address field names. By default the Geocode tool assumes the following names for the address fields:
- straat for straatnames (straatnaam)
- huisnr for house numbers (huisnummer)
- huisnr_toev for the combination of letter (huisletter) and addition (toevoeging)
- plaats for place (woonplaats)
- postcode for zipcode (postcode)
We advice to adjust the header of your source .csv file to use these names for the address fields. See special cases 1 if you want/need to adjust the names of these fields in the code.
Save the changes you made in the configuration/source files.
- Double click the item: export/bestand.
This will start the geocoding process and result in your source file extended with the XY coordinates and a set or meta information attributes.
The result is stored in the file "%LocalDataProjDir%/resultaat.csv (default C:/LocalData/BAG/Geocode/resultaat.csv), see folders and placeholders.
If you need to adjust the address fields in the code, go to the following code section:
container
postcode_org := Templates/uniformeer_string(...,Data/postcode);
...
attribute
woonplaats_vervangen (TableChopper/Domein) :=
MakeDefined(
rjoin(trim(data/plaats), ... , ...)
,data/plaats
);
...
container
straatnaam := Templates/uniformeer_string_straatnaam(...,
TableChopper/data/straat
);
container
huisnummer := Templates/uniformeer_string(… ,
TableChopper/data/huisnr
);
container
huistoevoeging := Templates/uniformeer_string(… ,
TableChopper/data/huisnr_toev
);
In this section you can define which address fields names are used in your source file. Adjust the bold values with the names of the address fields in your source file.
The geocode tool assumes all address fields are present in your source file. If e.g. your sourcefile does not contain a huisletter/toevoeging field, adjust the code:
container
huistoevoeging := Templates/uniformeer_string(TableChopper/Domein, TableChopper/data/toev);
to
container
huistoevoeging
{
attribute
resultaat (TableChopper/Domein) := const('''', TableChopper/Domein)
}
The const function results in an array with empty strings for the domain of the source file.
In some source files streetnames/numbers and additions are combined in one field.
With the tool you can split up such a composite field into it's components (for a small number of complex addresses this might not always result in correct values).
The code to split up such a composite field is already available in bron.dms, but default in comment.
To split up an address field with the name adres into it's street/housenumber/toevoeging, comment the current expression of the containers straatnaam, huisnummer and/or huistoevoeging in bron.dms and uncomment the by default commented expressions for these containers.
If the name of your composite field is not adres, we advice to adjust this in the header of your source file. If you can not adjust this, you can also edit the code line:
container
adres_splitsen
{
...
attribute
adres (TableChopper/Domein):=
TableChopper/Data/adres
;
}
and adjust the bold label adres into the name of your composite field.
If updating item: Export/bestand results in an error, check if:
- your %SourceDataDir%/BAG/snapshots.ext/date folder contains an adres.fss subfolder (result of the MakeSnapshot process).
- the item TeGeocoderen/bron/TableChopper/BestandsNaam refers to your source file.
- your source file is a valid csv file with a comma or semicolon delimiter. This delimiter need to be specified for the item: TeGeocoderen/bron/TableChopper/VeldScheidingsTeken
- your source address field names correspond with the names used in the code. If you open item: TeGeocoderen/bron you should see no red items.
BAG Toolkit