Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- ES-CL: the ITACyL server is https-only, the 2025 shapefiles sit in province subfolders, and C_REFREC is the identifier
- A test refuses a fixture above 5 MB, committed or merely lying in the fixture folder, because a failing convert test downloads the real source there
- ES-MD: find RECINTO.shp wherever the archive puts it
- BE-VLG: editions 2018-2026; REF_ID is published as block_id and the row index identifies the field, the QGIS styles table in the 2026 GeoPackage is skipped, and the 2020 archive is read as cp1252 with its CRS declared
- FI: one variant per year (2020-2025) instead of a hard-coded 2023, with the year in the cache name
- AT: extract the archive instead of reading the GeoPackage through /vsizip, which never finished for 2018
- SK: KODKD is the LPIS block code (non-unique, sometimes empty), so it is kept as block_id and the row index identifies the field
Expand Down
52 changes: 46 additions & 6 deletions fiboa_cli/datasets/be_vlg.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@


class Converter(AdminConverterMixin, AddHCATMixin, FiboaBaseConverter):
# Each archive holds one GeoPackage, but not under the name of the zip
# (2020 least of all), so glob for it rather than deriving it.
variants = {
str(k): {PREFIX + v: [v.replace("_GPKG.zip", ".gpkg")]}
str(k): {PREFIX + v: ["*.gpkg"]}
for k, v in (
(2026, "agpa_2026_2026-06-02_public.zip"),
(2025, "Landbouwgebruikspercelen_2025_-_Voorlopig_(extractie_02-06-2025)_GPKG.zip"),
(2024, "Landbouwgebruikspercelen_2024_-_Definitief_(extractie_27-03-2025)_GPKG.zip"),
(2023, "Landbouwgebruikspercelen_2023_-_Definitief_(extractie_28-03-2024)_GPKG.zip"),
Expand All @@ -34,17 +37,54 @@ class Converter(AdminConverterMixin, AddHCATMixin, FiboaBaseConverter):
attribution = "Bron: Dept. LV"
license = "Licentie modellicentie-gratis-hergebruik/v1.0 <https://data.vlaanderen.be/id/licentie/modellicentie-gratis-hergebruik/v1.0>"

# Fix cp1252 encoding for 2020
CP1252_EDITIONS = {"2020"}

def layer_filter(self, layer, uri):
# The 2026 GeoPackage carries a QGIS "layer_styles" table whose single
# row was read as a field.
return layer != "layer_styles"

def read_data(self, paths, **kwargs):
if self.variant in self.CP1252_EDITIONS:
kwargs["encoding"] = "cp1252"
return super().read_data(paths, **kwargs)

# the 2026 "agpa" edition renamed every column to English
RENAMES_2026 = {
"reference_id": "REF_ID",
"maincrop_code": "GWSCOD_H",
"maincrop_title": "GWSNAM_H",
"area_ha": "GRAF_OPP",
}

LAMBERT_72 = "EPSG:31370"

def migrate(self, gdf):
if gdf.crs is None or gdf.crs.to_epsg() is None:
gdf = gdf.set_crs(self.LAMBERT_72, allow_override=True)
if "maincrop_code" in gdf.columns:
gdf = gdf.rename(columns=self.RENAMES_2026)
if "BT_OMSCH" not in gdf.columns: # no farm-typology column any more
gdf["BT_OMSCH"] = None
return super().migrate(gdf)

index_as_id = True
columns = {
"geometry": "geometry",
"id": "id",
"BT_OMSCH": "typology",
"GRAF_OPP": "metrics:area",
"REF_ID": "id",
"REF_ID": "block_id",
"GWSCOD_H": "crop:code",
"GWSNAM_H": "crop:name",
}
column_additions = {
"determination:datetime": "2024-03-28T00:00:00Z",
}
use_variant_as_determination = True
ec_mapping_csv = "be_vlg_2021.csv"

missing_schemas = {"properties": {"typology": {"type": "string"}}}
missing_schemas = {
"properties": {
"typology": {"type": "string"},
"block_id": {"type": "string"},
}
}
Loading