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
- ES-CM: read the year-named SIGPAC service, whose id field is OBJECTID_1, with the determination date from the variant
- ES-CN: the seven island files each kept their own row index, and the region was declared as Cantabria
- EC-EE: name the shapefile inside the archive, migrate the year column the release actually has, and require only what every parcel carries
- ES-CAT: the 2024 download is a shapefile package, and 34 crop names new in that edition are mapped
Expand Down
36 changes: 18 additions & 18 deletions fiboa_cli/datasets/es_cm.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

class ESCMConverter(EsriRESTConverterMixin, ESBaseConverter):
id = "es_cm"
short_name = "Spain "
short_name = "Spain Castilla-La Mancha"
title = "Spain Castilla-La Mancha Crop fields"
description = """
SIGPAC is a Geographic Information System dedicated to the control of agricultural aid under
Expand All @@ -19,16 +19,18 @@ class ESCMConverter(EsriRESTConverterMixin, ESBaseConverter):
attribution = "Unidad de Cartografía. Secretaría General. Consejería de Agricultura, Ganadería y Desarrollo Rural."
provider = "Unidad de Cartografía. Secretaría General. Consejería de Agricultura, Ganadería y Desarrollo Rural. <https://datosabiertos.castillalamancha.es>"
columns = {
"dn_oid": "id",
"DN_OID": "id",
"geometry": "geometry",
"provincia": "admin_province_code",
"municipio": "admin_municipality_code",
"dn_surface": "metrics:area",
"uso_sigpac": "crop:code",
"PROVINCIA": "admin_province_code",
"MUNICIPIO": "admin_municipality_code",
"DN_SURFACE": "metrics:area",
"USO_SIGPAC": "crop:code",
"crop:name": "crop:name",
"crop:name_en": "crop:name_en",
}
use_code_attribute = "USO_SIGPAC"
area_is_in_ha = False
use_variant_as_determination = True
missing_schemas = {
"properties": {
"admin_province_code": {"type": "string"},
Expand All @@ -38,19 +40,17 @@ class ESCMConverter(EsriRESTConverterMixin, ESBaseConverter):
variants = {str(year): str(year) for year in range(2024, 2018 - 1, -1)}

rest_base_url = "https://geoservicios.castillalamancha.es/arcgis/rest/services/Vector"
rest_attribute = "objectid_1"
rest_attribute = "OBJECTID_1"

def get_urls(self):
latest_year = next(iter(self.variants))
if not self.variant:
self.variant = latest_year
if self.variant == latest_year:
layer = "Vector/Recintos_sigpac"
else:
services = requests.get(self.rest_base_url, {"f": "pjson"}).json()["services"]
layer = next(
s["name"]
for s in services
if re.search(f"Recintos_sigpac_{self.variant}", s["name"], re.IGNORECASE)
)
self.variant = next(iter(self.variants))
# Always use the year-named service: the unnamed "Recintos_sigpac" service is
# whatever year is current (2025 in August 2026) and keys on OBJECTID instead.
services = requests.get(self.rest_base_url, {"f": "pjson"}).json()["services"]
layer = next(
s["name"]
for s in services
if re.search(f"Recintos_sigpac_{self.variant}$", s["name"], re.IGNORECASE)
)
return {"REST": self.rest_base_url.replace("Vector", layer + "/MapServer")}
Binary file added tests/data-files/convert/es_cm/es_cm_0.gpkg
Binary file not shown.
2 changes: 2 additions & 0 deletions tests/test_convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
"ie",
"es_cat",
"es_cl",
"es_cm",
"es",
"nz",
"lt",
Expand Down Expand Up @@ -85,6 +86,7 @@ def _input_files(converter, *names):
"variant": "2025",
"input_files": {f"{test_path}/es_cl/AVILA.zip": ["replaceme.zip"]},
},
"es_cm": {"variant": "2024", **_input_files("es_cm", "es_cm_0.gpkg")},
"es_an": {
"variant": "2025",
"input_files": {f"{test_path}/es_an/SP25_REC_PROV_04.zip": ["SP25_REC_04.shp"]},
Expand Down
Loading