diff --git a/CHANGELOG.md b/CHANGELOG.md index ec2b7d5..2744127 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased] +- Converter for Bavaria, Germany - Update fr-converter to support 2021/2022 files ## [v0.21.0] - 2026-02-16 diff --git a/fiboa_cli/datasets/de_by.py b/fiboa_cli/datasets/de_by.py new file mode 100644 index 0000000..70b2926 --- /dev/null +++ b/fiboa_cli/datasets/de_by.py @@ -0,0 +1,41 @@ +import geopandas as gpd +from vecorel_cli.conversion.admin import AdminConverterMixin + +from ..conversion.fiboa_converter import FiboaBaseConverter +from .commons.hcat import AddHCATMixin, load_ec_mapping + + +class Converter(AdminConverterMixin, AddHCATMixin, FiboaBaseConverter): + sources = "https://geodaten.bayern.de/odd/m/3/daten/ln/landnutzung.gpkg" + avoid_range_request = True + + id = "de_by" + admin_subdivision_code = "BY" + short_name = "Germany, Bavaria" + title = "Field boundaries for Bavaria, Germany" + description = """A field block (German: "Feldblock") is a contiguous agricultural area surrounded by permanent boundaries, which is cultivated by one or more farmers with one or more crops, is fully or partially set aside or is fully or partially taken out of production.""" + license = "CC-BY-4.0" + attribution = "Datenquelle: Bayerische Vermessungsverwaltung – www.geodaten.bayern.de" + provider = "Bayerische Vermessungsverwaltung " + mapping_file = "https://fiboa.org/code/de/de_by.csv" + ec_mapping_csv = "https://fiboa.org/code/de/de_by.csv" + + columns = { + "geometry": "geometry", + "uuid": "id", + "datumderletztenueberpruefung": "determination:datetime", + "bewirtschaftung": "crop:code", + "crop:name": "crop:name", + } + + def layer_filter(self, layer: str, uri: str) -> bool: + return layer == "ln_landwirtschaft" + + def migrate(self, gdf: gpd.GeoDataFrame): + gdf = super().migrate(gdf) + self.ec_mapping = load_ec_mapping(self.ec_mapping_csv, url=self.mapping_file) + gdf = gdf[gdf["bewirtschaftung"].isin([row["original_code"] for row in self.ec_mapping])] + + mapping_crop = {row["original_code"]: row["original_name"] for row in self.ec_mapping} + gdf["crop:name"] = gdf["bewirtschaftung"].map(mapping_crop) + return gdf