Skip to main content

A CLI tool for downloading authoritative Spanish geospatial and address data.

Project description

trece

PyPI Latest Release License

Trece is a CLI tool for downloading and managing authoritative Spanish geospatial and address data, including administrative boundaries, road networks, postal codes, and address points for all Spanish provinces. The data is sourced from CartoCiudad, an official national geospatial database maintained by the Instituto Geográfico Nacional. Refer to Data Source and Attribution for more.

CartoCiudad data is widely used for mapping, spatial analysis, urban planning, and research. The data is open, regularly updated, and available in various formats suitable for GIS and data science workflows.

Each province's dataset is distributed as a GeoPackage (.gpkg) file, a spatial database format that supports multiple vector layers. It includes two main layers

  • portalpk_publi: Point layer representing address portals (building entrances) and kilometer markers along the road network. Each record contains

    • id: Unique identifier
    • geom: Point geometry (location)
    • id_porpk: Portal or kilometer marker ID
    • tipo_vial: Type of road/street
    • nombre_via: Street name
    • numero: Street number or kilometer
    • extension: Additional address info
    • dgc_via: Road code (from Dirección General de Catastro)
    • id_pob: Population entity ID
    • poblacion: Population entity name
    • cod_postal: Postal code
    • tipo_porpk: Portal/marker type
    • tipoporpkd: Portal/marker type description
    • fuented: Data source
    • fecha_modificacion: Last modification date
    • municipio: Municipality name
    • ine_mun: Municipality code (INE)
    • provincia: Province name
    • comunidad_autonoma: Autonomous community name
  • manzana: Polygon layer representing cadastral blocks (manzanas) as defined by the Spanish Cadastre and regional authorities. Each record contains

    • id: Unique identifier
    • geom: Polygon geometry (block shape)
    • ID_MANZ: Block identifier
    • ALTA_DB: Database registration date
    • INE_MUN: Municipality code (INE)

Coordinate Reference System:

  • Mainland Spain and Balearic Islands: ETRS89 (EPSG:4258)
  • Canary Islands: REGCAN95 (EPSG:4081)

All attributes are standardized for integration with GIS and spatial analysis tools. The data structure and schema are consistent across provinces, enabling automated processing and analysis.

Features

  • Fast & Simple: Download CartoCiudad data for all Spanish provinces with a single command.
  • Province Selection: Choose a province or fetch all at once.
  • Scriptable: Easily integrate into your data pipelines or automation scripts.

Getting Started

Installation

Install via PyPI

pip install trece

Quick Usage

Download CartoCiudad data for all provinces

trece download

or for a single province

trece download --province madrid

This will download a ZIP archive for the Madrid province at ./data/CARTOCIUDAD_CALLEJERO_MADRID.zip by default, but you can specify an output directory with the -o option. See the Options section for more.

Command Line Reference

trece [OPTIONS] COMMAND [ARGS]...

Commands

  • download — Download CartoCiudad data

Options

  • -v, --version — Print trece version
  • -h, --help — Show help message and exit
  • -p, --province — (For download) Specify a Spanish province (optional)
  • -o, --output — (For download) Output directory for downloaded files (optional)

Development

Clone the repository and install development dependencies:

git clone https://github.com/ernestofgonzalez/trece.git
cd trece
pip install -r requirements.txt

Run tests:

make test

Contributing

Contributions, issues, and feature requests are welcome! Feel free to check issues page or submit a pull request.

Data Source and Attribution

This project uses data from CartoCiudad, a product of the Instituto Geográfico Nacional (IGN) and Centro Nacional de Información Geográfica (CNIG), Spain. For more information, visit: CartoCiudad and SCNE Productos.

Attribution: Fuente: CartoCiudad. © Instituto Geográfico Nacional de España, Centro Nacional de Información Geográfica

Please review the full terms of use and attribution requirements at https://www.scne.es/productos.php#CartoCiudad

License

This project is licensed under the Apache License 2.0. See the LICENSE file for details.

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

trece-0.0.0a1.tar.gz (14.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

trece-0.0.0a1-py3-none-any.whl (11.7 kB view details)

Uploaded Python 3

File details

Details for the file trece-0.0.0a1.tar.gz.

File metadata

  • Download URL: trece-0.0.0a1.tar.gz
  • Upload date:
  • Size: 14.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for trece-0.0.0a1.tar.gz
Algorithm Hash digest
SHA256 9fcb75fc3b0d07119d753675ed5c2418e8731eeb1458e352193e425ee677c9eb
MD5 f3c34257b9d16af6b48979c1a9a9d7ba
BLAKE2b-256 83aa5f2ba605cf51353dc69729986db52818fe2782807a25dcb3cdaa08dc68ce

See more details on using hashes here.

File details

Details for the file trece-0.0.0a1-py3-none-any.whl.

File metadata

  • Download URL: trece-0.0.0a1-py3-none-any.whl
  • Upload date:
  • Size: 11.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for trece-0.0.0a1-py3-none-any.whl
Algorithm Hash digest
SHA256 f0b9a7b8e9580c18f9efc1b247df4b8386388d393c4b652aa3867b6ca1f07be3
MD5 076a26e2578198c32ceb92b150ca0425
BLAKE2b-256 3fc32b815bc5bbb9ddf47dd3c971eee97608690f0b07b798caa48acb31b52c13

See more details on using hashes here.

Supported by

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