Skip to content

Commit

Permalink
V56
Browse files Browse the repository at this point in the history
- Link to BAG changed as old one on Kadaster website was broken.
- Openbare ruimte object are now replace instead of insert, as the BAG sometimes contains multiple openbare ruimte objects with the same id.
  • Loading branch information
digitaldutch committed Jun 20, 2023
1 parent cedb0f0 commit dffa731
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
4 changes: 2 additions & 2 deletions config.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import locale

version = 55
version_date = '7 May 2023'
version = 56
version_date = '20 June 2023'

locale.setlocale(locale.LC_ALL, 'nl_NL')

Expand Down
9 changes: 6 additions & 3 deletions database_sqlite/database_sqlite.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,21 +61,24 @@ def save_openbare_ruimte(self, data):
data["naam"] = data["verkorte_naam"] if data["verkorte_naam"] != '' else data["lange_naam"]
else:
data["naam"] = data["lange_naam"]
# Note: Use replace, because BAG does not always contain unique id's
self.connection.execute(
"INSERT INTO openbare_ruimten (id, naam, lange_naam, verkorte_naam, type, woonplaats_id) "
"VALUES(?, ?, ?, ?, ?, ?)",
"""REPLACE INTO openbare_ruimten (id, naam, lange_naam, verkorte_naam, type, woonplaats_id)
VALUES(?, ?, ?, ?, ?, ?);
""",
(data["id"], data["naam"], data["lange_naam"], data["verkorte_naam"], data["type"], data["woonplaats_id"]))

def save_nummer(self, data):
# Note: Use replace, because BAG does not always contain unique id's
self.connection.execute(
"""REPLACE INTO nummers (id, postcode, huisnummer, huisletter, toevoeging, woonplaats_id, openbareruimte_id,
status) VALUES(?, ?, ?, ?, ?, ?, ?, ?)
status) VALUES(?, ?, ?, ?, ?, ?, ?, ?);
""",
(data["id"], data["postcode"], data["huisnummer"], data["huisletter"], data["toevoeging"],
data["woonplaats_id"], data["openbareruimte_id"], data["status"])
)


def save_pand(self, data):
# Note: Use replace, because BAG does not always contain unique id's
self.connection.execute(
Expand Down
2 changes: 1 addition & 1 deletion readme.MD
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ databases. There are a couple of options available in the [config.py](config.py)
`git clone https://github.com/digitaldutch/BAG_parser`
Update parser:
`git pull https://github.com/digitaldutch/BAG_parser`
* [Download the BAG (2.8 GB)](https://www.kadaster.nl/-/kosteloze-download-bag-2.0-extract) and save the file as `bag.zip` in the `input` folder.
* [Download the BAG (2.8 GB)](https://service.pdok.nl/kadaster/adressen/atom/v1_0/downloads/lvbag-extract-nl.zip) and save the file as `bag.zip` in the `input` folder.
* The [gemeenten.csv](input/gemeenten.csv) file is already included in the `input` folder, but you can [download the latest version from the CBS website](https://www.cbs.nl/nl-nl/onze-diensten/methoden/classificaties/overig/gemeentelijke-indelingen-per-jaar). Save it as `gemeenten.csv` in the input folder.
* Set your options in [config.py](config.py)
* Run `import_bag.py`
Expand Down

0 comments on commit dffa731

Please sign in to comment.