Can be used to download geodata from the GISCO API.
Installation
Unreleased version
git clone https://github.com/alecsandrei/gisco-geodata.git
cd gisco-geodata
python3 -m pip install .
PyPI
pip install gisco-geodata
Requirements
- httpx
- async-cache
- Python >= 3.9
- Optional: GeoPandas
Examples
Also check the examples folder.
import os
from pathlib import Path
from gisco_geodata import (
NUTS,
Countries,
set_httpx_args,
set_semaphore_value
)
if __name__ == '__main__':
out_dir = Path(
os.path.normpath(os.path.expanduser("~/Desktop"))
) # Desktop path
set_httpx_args(verify=False) # prevents SSLError in my case
set_semaphore_value(20) # the maximum number of asynchronous API calls
nuts = NUTS()
nuts.download(
file_format='shp',
year='2021',
spatial_type='BN',
scale='60M',
projection='4326',
nuts_level='LEVL_3',
out_dir=out_dir,
)
# Equivalent to the above
datasets = nuts.get_datasets()
datasets[-1].download(
file_format='shp',
spatial_type='BN',
scale='60M',
projection='4326',
nuts_level='LEVL_3',
out_dir=out_dir,
)
# Retrieve Country information as Polygons
countries = Countries()
# If you have geopandas installed, this will be a GDF.
gdf = countries.get(
countries=['RO', 'IT'],
spatial_type='RG',
)
if not isinstance(gdf, list):
print(gdf.head(5))
else:
print(gdf)
You can also use it with the eurostat python package.
"""To use this script you will need to also install the 'eurostat' and the 'mapclassify' packages."""
"""
To use this script you will need to also install the following packages
- eurostat
- geopandas
- mapclassify
"""
import geopandas as gpd
import matplotlib.pyplot as plt
from eurostat import get_data_df, get_toc_df, set_requests_args
from gisco_geodata import NUTS, set_httpx_args
def get_plot():
set_httpx_args(verify=False)
set_requests_args(verify=False)
# Get the geometries from the gisco service.
nuts = NUTS()
level_2 = nuts.get(spatial_type='RG', nuts_level='LEVL_2')
assert isinstance(level_2, gpd.GeoDataFrame)
# Get the dataset information.
eurostat_database = get_toc_df()
title, code = eurostat_database.loc[
eurostat_database['title']
== 'Unemployment by sex, age, educational attainment level and NUTS 2 region (1 000)',
['title', 'code'],
].iloc[0]
dataset = get_data_df(code)
assert dataset is not None
# Preprocess the dataset.
dataset = dataset.loc[
(dataset['isced11'] == 'TOTAL') & (dataset['sex'] == 'T')
] # total unemployment rate
# Join with the geometries.
dataset = level_2.merge(
dataset, left_on='NUTS_ID', right_on=r'geo\TIME_PERIOD'
)
assert isinstance(dataset, gpd.GeoDataFrame)
# Plot.
dataset.plot(
column='2023', scheme='NaturalBreaks', legend=True, edgecolor='black'
)
plt.title(title, fontdict={'size': 15, 'wrap': True})
plt.xlim(-25, 47)
plt.ylim(30, 75)
plt.tight_layout()
plt.show()
if __name__ == '__main__':
get_plot()
Disclaimer
This plugin, Eurostat Downloader, is an independent project created by Cuvuliuc Alex-Andrei. It is not an official product of Eurostat, and Cuvuliuc Alex-Andrei is not affiliated, associated, authorized, endorsed by, or in any way officially connected with Eurostat or any of its subsidiaries or its affiliates.
Copyright notice
Before using this package, please read the information provided by Eurostat.
Metadata
Release files for gisco-geodata 0.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| gisco_geodata-0.1.3.tar.gz | 152.9 kB | With provenance | Details for gisco_geodata-0.1.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| gisco_geodata-0.1.3-py3-none-any.whl | Python 3 | none | any | Details for gisco_geodata-0.1.3-py3-none-any.whl |
Total release size: 165.5 kB
Release files / gisco_geodata-0.1.3.tar.gz
| Download URL | gisco_geodata-0.1.3.tar.gz |
|---|---|
| Size | 152.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
997468da1a0abd3e285c14cd2c592afe13ba0cea5be934a1364bf137aea71063
|
|
BLAKE2b-256 checksum How to use checksums |
756c6c1d9108d026d6db7231267655b9693a90b7ee69d967c661ab0abffdd474
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Apr 25, 2025.
Transparency logRelease files / gisco_geodata-0.1.3-py3-none-any.whl
| Download URL | gisco_geodata-0.1.3-py3-none-any.whl |
|---|---|
| Size | 12.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
268180b4137ada4c118f88d1cc885cb4a59702a630ed09a32424ff6e44359f6c
|
|
BLAKE2b-256 checksum How to use checksums |
10404b4228835227617d63473051f4c23f20aee0f5ecbbb83157362a03ed5e82
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Apr 25, 2025.
Transparency logSecurity for gisco-geodata 0.1.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for gisco_geodata-0.1.3.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Apr 25, 2025.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.