Key:ref:ine

ref:ine
Group: References
Used on these elements
Status: de facto

Is a sub key of ref=* and its values are numbers used as identifiers for Spanish population units by the Spanish Statistical Office ( INE), P772.

Province Municipality Collective entity Singular entity Nucleus/scattering
PP MMM CC SS NN

Interactive map

You may check the current status of the missing references through the following visualization: https://osm-es.github.io/validador-ine/

Validation queries

Nodes

The spanish localities (i.e. place=*) ref:ine=* code lies in the value of ine:municipio=* plus 6 digits, therefore we can check it out using maths.

The next overpass query checks if the nodes contain the proper value, that is ine:municipio * 1e6 < ref:ine < ine:municipio * 1e6 + 1e6. If the following query returns nothing, it means everything is OK.

Note: The next query takes several minutes to run.

[out:xml][timeout:900];
area["ISO3166-1"="ES"]->.searchArea;
relation["admin_level"="8"]["boundary"="administrative"](area.searchArea);
map_to_area;
foreach->.mun(
  (
    // como no existe un operador de substring, convertimos ambas etiquetas a números
    // (debido a un error de parseo de variables que empiezan en cero, se añade y luego se resta, un número superior a los códigos)
    // como el ref:ine tiene 6 cifras añadidas a su ine:municipio, multiplicamos por 1 millón
    // de tal modo que los ref:ine deberá pertenecer al rango: 
    // ine:municipio * 1e6 < ref:ine < ine:municipio * 1e6 + 1e6
    //
    // ejemplo:
    // ine:municipio=47140
    // ref:ine=47140000100
    //
    // 47140 * 1e6 < 47140000100 < 47140 * 1e6 + 1e6
    node(area.mun)["ref:ine"](if: (number(1e12 + t["ref:ine"]) - 1e12) < ((number(1e12 + mun.u(t["ine:municipio"])) - 1e12) * 1e6));
    node(area.mun)["ref:ine"](if: (number(1e12 + t["ref:ine"]) - 1e12) > ((number(1e12 + mun.u(t["ine:municipio"])) - 1e12) * 1e6 + 1e6));
  );
  out;
);

Relations

The spanish municipalities (i.e. admin_level=8) ref:ine=* code lies in the value of ine:municipio=* plus 6 zeros, therefore we can check it out using maths.

The next overpass query checks if the relations contain the proper value, that is ine:municipio * 1e6 = ref:ine. If the following query returns nothing, it means everything is OK.

[out:xml][timeout:900];
area["ISO3166-1"="ES"]->.searchArea;
relation["admin_level"="8"]["boundary"="administrative"](area.searchArea)->.all;
relation.all["ref:ine"]->.ok;
// relaciones cuyo código ref:ine difiere del ine:municipio
// (debido a un error de parseo de variables que empiezan en cero, se añade y luego se resta, un número superior a los códigos)
//
// ejemplo:
// ine:municipio=47140
// ref:ine=47140000000
//
// 47140 * 1e6 = 47140000000
relation.ok(if: ((number(1e12 + _.set(t["ine:municipio"])) - 1e12) * 1e6) != (number(1e12 + _.set(t["ref:ine"])) - 1e12))->.wrong;
// relaciones sin código ref:ine
(.all; - .ok;)->.missing;
(.missing;.wrong;);
out geom;
This article is issued from Openstreetmap. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.