Skip to main content

GISCO Geodata is a Python package that provides access to the European Commission's GISCO geospatial data.

Project description

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."""

from gisco_geodata import (
    NUTS,
    set_httpx_args
)
from eurostat import (
    get_data_df,
    get_toc_df,
    set_requests_args
)
import geopandas as gpd
import matplotlib.pyplot as plt


if __name__ == "__main__":
    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()
    code = eurostat_database.loc[eurostat_database['title'] == 'Unemployment rate by NUTS 2 regions', '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='FID', right_on=r'geo\TIME_PERIOD')
    assert isinstance(dataset, gpd.GeoDataFrame)

    # Plot.
    dataset.plot(column='2023', scheme='NaturalBreaks', legend=True, edgecolor='black',
                 title='Unemployment rate by NUTS 2 regions, 2023')
    plt.show()

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gisco_geodata-0.1.1.tar.gz (12.3 kB view details)

Uploaded Source

Built Distribution

gisco_geodata-0.1.1-py3-none-any.whl (14.4 kB view details)

Uploaded Python 3

File details

Details for the file gisco_geodata-0.1.1.tar.gz.

File metadata

  • Download URL: gisco_geodata-0.1.1.tar.gz
  • Upload date:
  • Size: 12.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.9.19

File hashes

Hashes for gisco_geodata-0.1.1.tar.gz
Algorithm Hash digest
SHA256 ec730bb5378e46c84a907350d75de145be010373c749a6319a5ccfd4e84ee4a2
MD5 18692fef8c7c8e8065d9c793176ce14d
BLAKE2b-256 18ed52df14189c29a11476d0dcff6d14c5310f5ac47c09119cb8c2178d687a72

See more details on using hashes here.

File details

Details for the file gisco_geodata-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for gisco_geodata-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 58fb735ea7ce79b3afaeef31ae6e3ada995bc34dd06f3248826c78aaaaf731fc
MD5 25c9505b6390ebd0a1556623b77757d1
BLAKE2b-256 892d94fa4a55b0f52b1dff734e2105ab1daf08544810515d43b817f2fd370ee1

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page