No project description provided
Project description
Nuts Finder
You give it a point, it tells you all the EU NUTS regions.
Installation
pip install nuts-finder
Usage
from nuts_finder import NutsFinder
nf = NutsFinder() # <-- expect a little bit of loading time here whilst it downloads some shapefiles
nf.find(lat=53.406115, lon=-2.965604) # <-- pretty quick
>>> [{'CNTR_CODE': 'UK',
>>> 'FID': 'UK',
>>> 'LEVL_CODE': 0,
>>> 'NUTS_ID': 'UK',
>>> 'NUTS_NAME': 'UNITED KINGDOM'},
>>> {'CNTR_CODE': 'UK',
>>> 'FID': 'UKD',
>>> 'LEVL_CODE': 1,
>>> 'NUTS_ID': 'UKD',
>>> 'NUTS_NAME': 'NORTH WEST (ENGLAND)'},
>>> {'CNTR_CODE': 'UK',
>>> 'FID': 'UKD7',
>>> 'LEVL_CODE': 2,
>>> 'NUTS_ID': 'UKD7',
>>> 'NUTS_NAME': 'Merseyside'},
>>> {'CNTR_CODE': 'UK',
>>> 'FID': 'UKD72',
>>> 'LEVL_CODE': 3,
>>> 'NUTS_ID': 'UKD72',
>>> 'NUTS_NAME': 'Liverpool'}]
Give me the shapes
You can access all of the NUTS boundaries via:
nf = NutsFinder()
nf.shapes
>>> {"crs": {"properties": {"name": "urn:ogc:def:crs:EPSG::4326"}, "type": "name"}, "features": [{"geometry": {"coordinates": [[[16.107, 50.662], [16.333, 50.592], [16.58, 50.143], [15.438, 50.11], [15.147, 50.523], [15.42, 50.5], [15.584, 50.627], [15.535, 50.779], [16.107, 50.662]]], "type": "Polygon"}, "id": "CZ052", "properties": {"CNTR_CODE": "CZ", "FID": "CZ052", "LEVL_CODE": 3, "NUTS_ID": "CZ052", "NUTS_NAME": "Kr\\u00e1lov\\u00e9hradeck\\u00fd kraj"}, "type": "Feature"}, ...}
Advanced usage
The look-up is performed via point-in-polygon tests from the official repository of NUTS shapefiles. You can additionally specify the year (year
) and scale (1:scale
Million) of the downloaded shapefiles as follows:
nf = NutsFinder(year=2013, scale=60)
Note that the default year is the latest available, and the scale is the median available. At time of writing the available years were {2003, 2006, 2010, 2013, 2016}
and available scales were {1, 3, 10, 20, 60}
.
Points near rivers and coastlines
Unless you use scale=1
, expect to lose some coverage of points very near to water features (coastal and river regions). If you would like to optimise for speed, you might consider a recursive strategy of using a coarser NutsFinder
followed by a more granular one to pick up missed points.
Speed-ups
The find(...)
method is significantly faster for coarser geographical scales. For most purposes, a scale of around 10 should be sufficient. See below for a benchmark on my laptop (macOS, 2.3 GHz, 16GB) against the scales available at the time of writing:
scale |
time |
---|---|
1 | 2.66 s ± 191 ms per loop |
3 | 608 ms ± 15 ms per loop |
10 | 215 ms ± 1.85 ms per loop |
20 | 145 ms ± 11.6 ms per loop |
60 | 105 ms ± 14 ms per loop |
Eurostat copyright notice
Please note that nuts-finder
is not developed, maintained or affiliated with Eurostat. The following copyright notice from Eurostat regards their data, which underpins nuts-finder
:
In addition to the general copyright and licence policy applicable to the whole Eurostat website, the following specific provisions apply to the datasets you are downloading. The download and usage of these data is subject to the acceptance of the following clauses:
The Commission agrees to grant the non-exclusive and not transferable right to use and process the Eurostat/GISCO geographical data downloaded from this page (the "data").
The permission to use the data is granted on condition that:
- the data will not be used for commercial purposes;
- the source will be acknowledged. A copyright notice, as specified below, will have to be visible on any printed or electronic publication using the data downloaded from this page.
Copyright notice
When data downloaded from this page is used in any printed or electronic publication, in addition to any other provisions applicable to the whole Eurostat website, data source will have to be acknowledged in the legend of the map and in the introductory page of the publication with the following copyright notice:
- EN: © EuroGeographics for the administrative boundaries
- FR: © EuroGeographics pour les limites administratives
- DE: © EuroGeographics bezüglich der Verwaltungsgrenzen
For publications in languages other than English, French or German, the translation of the copyright notice in the language of the publication shall be used.
If you intend to use the data commercially, please contact EuroGeographics for information regarding their licence agreements.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file nuts_finder-21.5.5.14.tar.gz
.
File metadata
- Download URL: nuts_finder-21.5.5.14.tar.gz
- Upload date:
- Size: 6.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ab57ea0c2064c587ae22da60803a1627bd7df814ad332d37aba9cee4ca87483b |
|
MD5 | 577ee3d5022601027d3ac1035846caee |
|
BLAKE2b-256 | 0e9c59f6e569ef6f3c2214bb2982327e323de27830d89785c1860bfdf06eb186 |
File details
Details for the file nuts_finder-21.5.5.14-py3-none-any.whl
.
File metadata
- Download URL: nuts_finder-21.5.5.14-py3-none-any.whl
- Upload date:
- Size: 6.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 38f39c896cc729b38fbd5daa656b09dbef65eb1f269fcf549fcb2993ab5b2bc7 |
|
MD5 | ea658a99bcaea3996429b65195eb3069 |
|
BLAKE2b-256 | 5d3271708614740d668f8fd9e6ac4178f72d3de3ab7cefe6f62a9d9ce0162048 |