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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- DK:
- IDs are now derived from `Journalnr` and `Marknr` together (or the row number in editions without either), because `Marknr` alone repeats across holdings.
- Missing crop codes are kept empty instead of being filled with the undefined code 0.
- EC-BE-VLG: Converting no longer fails on the variants inherited from BE-VLG.
- EC-EE: Fixed shapefile naming and year-column migration.
- EC-FR: Added the missing 2018 RPG campaign from EuroCrops.
- EC-LT:
Expand All @@ -107,6 +108,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- EC-SI: Relaxed requirements to match fields present in source data.
- EE: Published valid crop code, land-use class and stable parcel identifier; cache files are now campaign-specific.
- ES:
- ES now maps crops to HCAT, and `crop:code_list` points to a code list that exists.
- ES-AN now uses the correct land-use column and campaign-based determination date.
- ES-CAT and ES-CN now map crop codes to HCAT with the extended mapping table.
- ES-CB now derives determination date from the campaign.
Expand All @@ -122,6 +124,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Crop codes introduced after the 2018 EuroCrops table (for example JAC, the most common code of 2024) now map to HCAT; 7.50% of the 2024 fields were unmapped before.
- `id` is the RPG parcel id plus a part number where it repeats (multipart splits, reissued ids); the source value is kept as `parcel_id`.
- IE: Uses stable feature IDs and publishes computed `metrics:area` when missing from source.
- IE-LPIS: The HCAT mapping is read again; it still used the attribute name from before the rename.
- JP: Uses campaign-specific determination dates and DuckDB conversion path.
- LT: Updated to Europe-LAND v1.3 with 2025 coverage.
- SK: Fixed edition selection, crop-name matching and block/id handling across campaigns.
Expand Down
2 changes: 1 addition & 1 deletion fiboa_cli/datasets/commons/hcat.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def map_by_name(attribute):
if name_col is not None:
col = col.fillna(name_col.str.strip().map(map_by_name(v)))
gdf[k] = col
assert np.unique(col[~col.isna()]).size > 1, "No HCAT crops mapped"
assert np.unique(col[~col.isna()]).size > 0, "No HCAT crops mapped"

if col is not None and col.isna().any():
index = [
Expand Down
2 changes: 2 additions & 0 deletions fiboa_cli/datasets/ec_be_vlg.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ class ECConverter(EuroCropsConverterMixin, BEVLGBaseConverter):
"BE_VLG_2021/BE_VLG_2021_EC21.shp"
]
}
# the single EuroCrops 2021 release, not the parent's yearly editions
variants = {}
Comment on lines +12 to +13

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
Expand Down
13 changes: 7 additions & 6 deletions fiboa_cli/datasets/es.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
from vecorel_cli.vecorel.extensions import ADMIN_DIVISION

from ..conversion.fiboa_converter import FiboaBaseConverter
from .commons.hcat import AddHCATMixin


class Converter(FiboaBaseConverter):
class Converter(AddHCATMixin, FiboaBaseConverter):
id = "es"
short_name = "Spain"
title = "Spain Declared Crops (Cultivos Declarados SIGPAC)"
Expand All @@ -25,6 +26,9 @@ class Converter(FiboaBaseConverter):

variants = {"2025": "2025"}

# FEGA declared-crop codes (PARC_PRODUCTO) to HCAT; the mixin also publishes it as crop:code_list
hcat_mapping_csv = "https://fiboa.org/code/es/es.csv"

columns = {
"geometry": "geometry",
"id": "id",
Expand All @@ -45,14 +49,11 @@ class Converter(FiboaBaseConverter):

column_additions = {
"admin:country_code": "ES",
# FEGA declared-crop codelist (PARC_PRODUCTO) — separate from the SIGPAC land-use list.
# Reference list shipped inside each provincial GPKG as the `cod_producto` layer.
"crop:code_list": "https://fiboa.org/code/es/cultivos_declarados/parc_producto.csv",
}

column_migrations = {
# crop:code must be a string per the crop extension; parc_producto is an integer.
"parc_producto": lambda col: col.astype("Int64").astype(str),
# crop:code must be a string per the crop extension; 0 is "unknown product" in the code list
"parc_producto": lambda col: col.astype("Int64").fillna(0).astype(str),
# admin_*_code are strings; zero-pad province to 2 digits (INE convention).
"provincia": lambda col: col.astype("Int64").astype(str).str.zfill(2),
"municipio": lambda col: col.astype("Int64").astype(str),
Expand Down
2 changes: 1 addition & 1 deletion fiboa_cli/datasets/ie_lpis.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class Converter(AdminConverterMixin, AddHCATMixin, FiboaBaseConverter):
provider = "Department of Agriculture, Food and the Marine <https://data.gov.ie/organization/department-of-agriculture-food-and-the-marine>"
attribution = "Ireland Department of Agriculture, Food and the Marine"
license = "CC-BY-4.0"
ec_mapping_csv = (
hcat_mapping_csv = (
"https://fiboa.org/code/ie/ie.csv" # the GSAA list, extended by the LPIS-only names
)
area_is_in_ha = False
Expand Down
16 changes: 16 additions & 0 deletions tests/test_converters.py
Original file line number Diff line number Diff line change
Expand Up @@ -453,3 +453,19 @@ def square(x, side):
# one value for every row, so it is written to the collection metadata
collection = json.loads(pq.ParquetFile(tmp_parquet_file).schema_arrow.metadata[b"collection"])
assert collection["determination:datetime"] == "2025-01-01T00:00:00Z"


def test_no_converter_declares_both_sources_and_variants():
c = Converters()
for _id in c.list_ids():
c.load(_id)._require_one_source_of_urls()


def test_no_converter_uses_the_old_hcat_attribute_names():
# renamed in #320; a converter still setting ec_mapping* is silently ignored
c = Converters()
old = {
_id: [a for a in dir(type(c.load(_id))) if a.startswith("ec_mapping")]
for _id in c.list_ids()
}
assert not {k: v for k, v in old.items() if v}
Loading