Skip to content
Closed
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 @@ -11,6 +11,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
- JP: editions 2021-2024, each with the determination date of the parcel rather than a constant
- PerFileBaseConverter: convert a multi-file source one file at a time and merge the parts, so a dataset larger than memory can be converted; used by the Spain-wide converter
- FiboaDuckDBBaseConverter: convert a source that is already Parquet with SQL, without loading it into memory
- Update vecorel-cli to v0.2.17:
Expand Down
19 changes: 5 additions & 14 deletions fiboa_cli/datasets/jp.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import pandas as pd
from fiboa_cli.conversion.duckdb import FiboaDuckDBBaseConverter

from ..conversion.fiboa_converter import FiboaBaseConverter


class JPConverter(FiboaBaseConverter):
class JPConverter(FiboaDuckDBBaseConverter):
variants = {
"2024": "https://data.source.coop/pacificspatial/field-polygon-jp/parquet/jp_field_polygons_2024.parquet",
"2023": "https://data.source.coop/pacificspatial/field-polygon-jp/parquet/jp_field_polygons_2023.parquet",
"2022": "https://data.source.coop/pacificspatial/field-polygon-jp/parquet/jp_field_polygons_2022.parquet",
"2021": "https://data.source.coop/pacificspatial/field-polygon-jp/parquet/jp_field_polygons_2021.parquet",
"test": "./tests/data-files/convert/jp/jp_field_polygons_2024.parquet",
}

id = "jp"
Expand All @@ -32,21 +31,13 @@ class JPConverter(FiboaBaseConverter):
"local_government_cd": "admin_local_code",
"issue_year": "determination:datetime",
}
# SQL migrations (DuckDB converter): per-feature determination date from the issue year
column_migrations = {
"issue_year": lambda col: pd.to_datetime(col, format="%Y"),
"issue_year": "make_timestamp(CAST(issue_year AS INTEGER), 1, 1, 0, 0, 0) AT TIME ZONE 'UTC'",
}

missing_schemas = {
"properties": {
"land_type_en": {"type": "string"},
"admin_local_code": {"type": "string"},
}
}

def convert(self, *args, **kwargs):
# Open only these columns to limit memory usage
super().convert(
*args,
columns=["GEOM", "polygon_uuid", "land_type_en", "local_government_cd", "issue_year"],
**kwargs,
)