Key:ref:ine
| Description |
|---|
| Identifier for population units by the National Statistical Offices, both Spain and Portugal |
| Group: references |
| Used on these elements |
| Useful combination |
|
| See also |
| Status: de facto |
| Tools for this tag |
|
It is a subkey of ref=* and its values are numbers used as identifiers for population units, both by the
Instituto Nacional de Estadística (Spain),
P772 and the
Instituto Nacional de Estatística (Portugal),
P6324, even though their composition differs.
Spain
| Subdivision | Digits | Reference formula | Notes |
|---|---|---|---|
| Province | PP | -- | There is no ref:ine=* for provinces admin_level=6
|
| Municipality | MMM | ine:municipio=* (PP + MMM) + "000000"
|
Only for relations boundary=administrative and admin_level=8
|
| Collective entity | CC | ine:municipio=* (PP + MMM) + CC + "0000"
|
Only for relations boundary=administrative and admin_level=9
|
| Singular entity | SS | ine:municipio=* (PP + MMM) + CC + SS + "00"
|
If the entity is a node, do not use this code, the nucleus code is preferable |
| Nucleus/scattering | NN | ine:municipio=* (PP + MMM) + CC + SS + NN
|
Only for nodes: in nucleus elements NN can be 01, 02, 03, 04, etc... and in scattered elements NN is equal to 99 |
Interactive map
You may check the current status of the missing and leftover 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"]["ine:municipio"]["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;
);
Likewise, we can further refine the entities validation, instead of consulting by municipality we do so by a lower unit, such as, the civil parishes for Galicia and Asturias, or the deputations/districts for Region of Murcia. A reference will be correct whenever: ref:ine parish < ref:ine locality < ref:ine parish + 1e4. If the following query returns nothing, it means everything is OK.
Note: This query will make sense whenever the municipalities contain boundary=administrative and admin_level=9 relations.

[out:xml][timeout:900];
area["ISO3166-2"="ES-GA"]->.searchArea;
relation["admin_level"="9"]["boundary"="administrative"](area.searchArea);
map_to_area;
foreach->.mun(
(
node(area.mun)["ref:ine"](if: (number(1e12 + t["ref:ine"]) - 1e12) < (number(1e12 + mun.u(t["ref:ine"])) - 1e12));
node(area.mun)["ref:ine"](if: (number(1e12 + t["ref:ine"]) - 1e12) > (number(1e12 + mun.u(t["ref:ine"])) - 1e12 + 1e4));
);
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"]["ine:municipio"]["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;
Portugal
(To be done once the portuguese wiki is made)
