The problem
You have addresses or geographic coordinates (longitude and latitude)
and you want to
know the NUTS codes of the location.
Overview
EU NUTS (an abbreviation for
Nomenclature of Territorial Units for Statistics)
codes are standardized codes used by the European Union to define
administrative and statistical regions for the purpose of data
collection and analysis. They are used to identify, classify, and
aggregate data on regions within the EU for statistics, planning, and
policy making.
Converting addresses and/or geocoordinates (longitude, latitude) into NUTS codes as a way to aggregate data is a common task for statistical researchers.
You can use the OpenCage geocoding API to find the relevant NUTS codes for a location in EU countries (current member states), EFTA countries, and some EU candidate countries. See the full list below in the Caveats section.
You can test our geocoding API manually on our demo page.
Background
When you send an API request to the OpenCage geocoding API
with each result we return various fields about the location of the
result (what we refer to in our API documentation as
annotations).
For locations in the EU member states we return a
NUTS
annotation for each result with the subfields:
-
NUTS0
The NUTS country code.
Example:DE -
NUTS1
Major socio-economic regions, e.g. groups of federal states or large regions.
Example:DE3 -
NUTS2
Smaller regions, the level most commonly used for regional statistics and EU structural funding decisions.
Example:DE30 -
NUTS3
The smallest NUTS level, roughly comparable to a county or district.
Example:DE300
Caveats
There are a few points you should note when working with the NUTS codes
returned by the OpenCage geocoding API.
- Countries are structured differently, as is perhaps to be expected given that some countries are very large, and others much smaller. Some countries have many level 3 NUTS codes, others only one.
- Currently we return NUTS codes only for EU member states, EFTA countries (CH, IS, LI, NO), and some EU candidate countries (AL, ME, MK, RS, TR). We may in the future add more candidate countries and former EU member states (the UK). If this is preventing you from becoming a customer please get in touch with us, and let's discuss.
- We do not currently offer LAU codes (the level below NUTS3). If you need LAU, Eurostat publishes NUTS-LAU correspondence tables you can join against our NUTS3 output.
Code example
Here's a small example of making a geocoding request to the
OpenCage API in javascript to determine the NUTS code of the
coordinates
52.5432379, 13.4142133
- site of the OpenCage office in Berlin, Germany.
var api_key = 'YOUR-API-KEY';
var coords = '52.5432379, 13.4142133'; // lat, lng
var api_url = 'https://api.opencagedata.com/geocode/v1/json'
var request_url = api_url
+ '?'
+ 'key=' + api_key
+ '&q=' + encodeURIComponent(coords)
+ '&pretty=1';
// see full list of required and optional parameters:
// https://opencagedata.com/api#forward
var request = new XMLHttpRequest();
request.open('GET', request_url, true);
request.onload = function() {
// see full list of possible response codes:
// https://opencagedata.com/api#codes
var data = JSON.parse(request.responseText);
if (request.status === 200){ // Success!
var nuts = 'no NUTS codes returned';
if (data.results[0].annotations.NUTS != null){
nuts = data.results[0].annotations.NUTS;
}
console.log('NUTS: ' + nuts);
} else {
console.log("unable to geocode! Response code: " + request.status);
console.log('error msg: ' + data.status.message);
}
};
request.onerror = function() {
// There was a connection error of some sort
console.log("unable to connect to server");
};
request.send(); // make the request
Further reading
Happy geocoding!
2,500 geocoding API requests/day - No credit card required