This is the old version of our wiki. We advice to visit: https://www.geodms.nl

How to use the geocode script

From ObjectVision

Jump to: navigation, search

GeoCode How to use the script

Contents

steps

1. Make sure you have an adres.fss subfolder in your snapshot folder, see MakeSnapshot.

2. Configure the snapshot date: Open the Geocode.dms file from the BAG toolkit scripts (in the cfg subfolder of your chosen project folder) in a text editor. Configure the item: BAG/impl/SnapshotDir

parameter<string> SnapshotDir := '%SourceDataDir%/BAG/snapshots.ext/20160401';

Adjust the date of this SnapshotDir using the format yyyymmdd to the Snapshot date you made with the MakeSnapshot tool.

3. Configure the source file with the addresses to be geocoded: Open the bron.dms file (in the cfg/geocode subfolder of your chosen project folder) in a text editor. Configure the item bron/TableChopper/BestandsNaam:

parameter<string> BestandsNaam := '%SourceDataDir%/BAG/xy_source/input_addresses.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 comma, a semicolon can also be used, in that case configure this for the item: bron/TableChopper/VeldScheidingsTeken.

4. 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.

5. 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.

Special cases

1. adjust address field names in code

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<string> 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.

2. missing address fields

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<string> resultaat (TableChopper/Domein):= const(, TableChopper/Domein)
}

The const function results in an array with empty strings for the domain of the source file.

3. streetnames, housenumbers, houseletters and additions in one field

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<string> adres (TableChopper/Domein):= TableChopper/Data/adres;
}

and adjust the bold label adres into the name of your composite field.

Troubleshooting

If updating item: Export/bestand results in an error, check if:

  1. your %SourceDataDir%/BAG/snapshots.ext/date folder contains an adres.fss subfolder (result of the MakeSnapshot process).
  2. the item TeGeocoderen/bron/TableChopper/BestandsNaam refers to your source file.
  3. 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
  4. 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.
Personal tools