dieghernan

@dieghernan.bsky.social

From postal code points to polygons! Can we estimate postal code boundaries using open data and R? In my latest post, I explore Voronoi diagrams with {sf}, {giscoR} and {ggplot2}, using Slovenia as a case study. #rstats #rspatial #maps dieghernan.github.io/202611_posta...

Postal codes and tessellations | One World

Build Voronoi polygons with R, then estimate postal code areas in Slovenia using giscoR and sf, with checks and a discussion of the data limitations.

dieghernan.github.io

¡De puntos a polígonos postales! ¿Podemos estimar los límites de los códigos postales con datos abiertos y R? En mi nuevo post exploro los diagramas de Voronoi con {sf}, {giscoR} y {ggplot2}, usando Eslovenia como ejemplo. #rstats #rspatial #maps dieghernan.github.io/202611_posta...

Postal codes and tessellations | One World

Build Voronoi polygons with R, then estimate postal code areas in Slovenia using giscoR and sf, with checks and a discussion of the data limitations.

dieghernan.github.io

Do you know the interrupted Goode homolosine projection?

Let’s peel the world

https://fed.brid.gy/ What would happen if we peeled the Earth like an orange? The interrupted Goode homolosine projection gives us something close to that! This equal-area projection preserves relative areas while splitting the world map into lobes. Add a few shades of orange and our world is ready to peel. Let’s make it with **sf** , **giscoR** and **ggplot2**. First, we get the coastlines and draw the outline, following the cuts between the lobes. library(sf) library(ggplot2) library(giscoR) world <- gisco_get_coastal_lines(resolution = 10) goode_crs <- "+proj=igh" lat <- c(90:-90, rep(c(-90:0, 0:-90), 3), -90:90, 90:0, 0:90, 90) lon <- c( rep(180, 181), rep(c(80.01, 79.99, -19.99, -20.01, -99.99, -100.01), each = 91), rep(-180, 181), rep(c(-40.01, -39.99), each = 91), 180 ) outline <- st_sfc(st_polygon(list(cbind(lon, lat))), crs = 4326) |> st_transform(goode_crs) rectangle <- st_as_sfc(st_bbox(outline) * 1.1) mask <- st_difference(rectangle, outline) Next, we draw the meridians and parallels within each lobe so that they do not connect across the cuts. lobes <- list( c(-180, -40, 0, 90), c(-40, 180, 0, 90), c(-180, -100, -90, 0), c(-100, -20, -90, 0), c(-20, 80, -90, 0), c(80, 180, -90, 0) ) lines <- lapply(lobes, function(b) { west <- b[1] + 0.01 east <- b[2] - 0.01 south <- max(b[3], -89.99) north <- min(b[4], 89.99) meridians <- seq(-180, 180, 30) meridians <- meridians[meridians > west & meridians < east] parallels <- seq(-60, 60, 30) parallels <- parallels[parallels >= south & parallels <= north] c( lapply(meridians, function(x) { st_linestring(cbind(x, seq(south, north, length.out = 181))) }), lapply(parallels, function(y) { st_linestring(cbind(seq(west, east, length.out = 361), y)) }) ) }) grat <- st_sfc(do.call(c, lines), crs = 4326) |> st_transform(goode_crs) Finally, we add the orange palette. The mask hides anything outside the outline and keeps the edges of our peel tidy. ggplot() + geom_sf(data = outline, fill = "#FFF0D9", colour = NA) + geom_sf(data = world, fill = "#F9B566", colour = "#B34D08", linewidth = 0.25) + geom_sf(data = grat, fill = NA, colour = "#E8A45B", linewidth = 0.25) + geom_sf(data = mask, fill = "white", colour = NA) + geom_sf(data = outline, fill = NA, colour = "#E87516", linewidth = 0.4) + coord_sf( crs = goode_crs, xlim = st_bbox(outline)[c("xmin", "xmax")], ylim = st_bbox(outline)[c("ymin", "ymax")], expand = FALSE, datum = NA ) + theme_void() + theme( plot.background = element_rect(fill = "white", colour = NA), plot.title = element_text(color = "#E87516", face = "bold") ) + labs( title = "Let's peel the world", caption = "Interrupted Goode homolosine projection" ) ## References The outline and masking approach follows Claus O. Wilke’s Interrupted Goode homolosine example. For more on map projections, see Pyranhia’s Projections cartographiques : le guide pour ne pas y laisser sa santé mentale (in French).

dieghernan.github.io

A compilation of celestial data files

Celestial data

This project provides several datasets of celestial objects as of the J2000 epoch in GeoJSON and GeoPackage formats. The original files were provided by the d3-celestial plugin (Frohn 2015) under BSD 3-Clause. The datasets produced by this project consist of the same data provided by the d3-celestial plugin processed with the **R** package **sf** (Pebesma 2018) to ensure its validity: * The spatial data objects are bounded by \\([-180, -90, 180, 90]\\). * Data are provided in WGS 84 - World Geodetic System 1984 (EPSG:4326). * All geometries are valid as per ST_IsValid (GEOS **3.9.3**). ## Distribution The data can be accessed from several API endpoints: <!-- From GitHub --> https://raw.githubusercontent.com/dieghernan/celestial_data/main/data/mw.min.geojson <!-- From the website --> https://dieghernan.github.io/celestial_data/data/mw.min.geojson <!-- From jsDelivr --> https://cdn.jsdelivr.net/gh/dieghernan/celestial_data@main/data/mw.min.geojson ## Data Data are provided in GeoJSON (`*.geojson`) and GeoPackage (`*.gpkg`) formats. Additionally, for GeoJSON files a minified version (`*.min.geojson`) is also provided. The data source can be found in the corresponding GitHub repo. List of files provided: * `asterisms.geojson` * `asterisms.gpkg` * `asterisms.min.geojson` * `constellations.borders.cn.geojson` * `constellations.borders.cn.gpkg` * `constellations.borders.cn.min.geojson` * `constellations.borders.geojson` * `constellations.borders.gpkg` * `constellations.borders.min.geojson` * `constellations.borders.min.min.geojson` * `constellations.bounds.cn.geojson` * `constellations.bounds.cn.gpkg` * `constellations.bounds.cn.min.geojson` * `constellations.bounds.geojson` * `constellations.bounds.gpkg` * `constellations.bounds.min.geojson` * `constellations.cn.csv` * `constellations.cn.geojson` * `constellations.cn.gpkg` * `constellations.cn.min.geojson` * `constellations.csv` * `constellations.geojson` * `constellations.gpkg` * `constellations.lines.cn.geojson` * `constellations.lines.cn.gpkg` * `constellations.lines.cn.min.geojson` * `constellations.lines.geojson` * `constellations.lines.gpkg` * `constellations.lines.min.geojson` * `constellations.min.geojson` * `dsonames.cn.csv` * `dsonames.csv` * `dsos.14.geojson` * `dsos.14.gpkg` * `dsos.14.min.geojson` * `dsos.20.geojson` * `dsos.20.gpkg` * `dsos.20.min.geojson` * `dsos.6.geojson` * `dsos.6.gpkg` * `dsos.6.min.geojson` * `dsos.bright.geojson` * `dsos.bright.gpkg` * `dsos.bright.min.geojson` * `lg.geojson` * `lg.gpkg` * `lg.min.geojson` * `messier.geojson` * `messier.gpkg` * `messier.min.geojson` * `mw.geojson` * `mw.gpkg` * `mw.min.geojson` * `starnames.cn.csv` * `starnames.csv` * `stars.14.geojson` * `stars.14.gpkg` * `stars.14.min.geojson` * `stars.6.geojson` * `stars.6.gpkg` * `stars.6.min.geojson` * `stars.8.geojson` * `stars.8.gpkg` * `stars.8.min.geojson` See additional details in the data description. ## Citation Please cite these datasets as: Frohn, O., & Hernangómez, D. (2023). Celestial Data [Data set]. https://doi.org/10.5281/zenodo.7561601 A BibTeX entry: @misc{frohnhernangomez:2023, title = {Celestial Data}, author = {Olaf Frohn and Diego Hernangómez}, year = 2023, doi = {10.5281/zenodo.7561601}, url = {https://dieghernan.github.io/celestial_data/}, } ## References Frohn, Olaf. 2015. “d3-celestial” https://github.com/ofrohn/d3-celestial/. Pebesma, Edzer. 2018. “Simple Features for R: Standardized Support for Spatial Vector Data.” _The R Journal_ 10 (1): 439446. https://doi.org/10.32614/RJ-2018-009.

dieghernan.github.io

Estimated postal code areas from open data

Postal codes of Spain

**Códigos postales de España** provides estimated postal code areas for Spain, built from open address data from CartoCiudad and administrative boundaries. Explore the results on interactive maps and download the data for use in **R** , **Python** or **QGIS**. ## Background Postal code polygons are useful for linking addresses and statistics to areas on a map. According to Goerlich (2022), the Correos polygons available through CartoCiudad stopped being offered for download in early 2017. This project explores a reproducible alternative based on open address data. An early reference is José Ignacio Sánchez’s 2020 article in NoSoloSIG, which describes how to estimate postal areas from CartoCiudad addresses using GIS tools. This project applies the approach developed in Francisco José Goerlich’s 2022 work, with its own choices for selecting addresses and handling areas without an assignment. ## Maps and data The project website includes interactive maps and two GeoPackage downloads: a full version for spatial analysis and a simplified version for visualization. Both include postal code areas and administrative areas pending assignment. The data is shared under a Creative Commons Attribution 4.0 International license. ### Interactive map Search for a postal code or address, select a two-digit prefix and compare the estimated areas with CartoCiudad. The viewer uses the simplified data and does not display areas pending assignment. Its controls are in Spanish. Open the map in a full window Viewer guide ## Methodology Following Goerlich’s approach, the workflow treats each separate component of an administrative area independently. When the selected addresses share a single postal code, it assigns that code to the whole component. When several codes are present, it builds Voronoi polygons around the address locations, clips them to the administrative boundary and merges areas with the same code. The final polygons are dissolved by postal code across provinces. This implementation selects addresses using an inward buffer of 200 m, with a second attempt at 50 m if none are found, rather than the 20 m described by Goerlich. Components without selected addresses remain unassigned unless the municipality has a single postal code recovered from its other components. The administrative boundaries come from LAU2boundaries4Spain, by Francisco José Goerlich and Pedro Pérez Vázquez. These are estimated areas, not official postal boundaries. Coverage depends on the source addresses and some areas remain unassigned. The repository documents the sources, methodology, limitations and steps to reproduce the data. ## References * Instituto Geográfico Nacional / Centro Nacional de Información Geográfica (IGN/CNIG). (n.d.). _CartoCiudad_ [Dataset]. Data portal. * Instituto Geográfico Nacional / Centro Nacional de Información Geográfica (IGN/CNIG). (n.d.). _Servicios de visualización de CartoCiudad: direcciones y códigos postales_. WMS documentation. * Correos. (n.d.). _Base de datos de códigos postales y capa cartográfica_. Product information. * Goerlich, F. J. (2022). _Elaboración de un mapa de códigos postales de España con recursos libres. Cómo evitar pagar por disponer de información de referencia_. Working Papers Ivie, no. 2022-3. Ivie. doi:10.12842/WPIVIE_0322. * Goerlich, F. J., & Pérez Vázquez, P. (2025). _Base de datos histórica de contornos municipales de España –LAU2boundaries4Spain–_ (version v2) [Dataset]. Zenodo. doi:10.5281/zenodo.15345101. * Hernangómez, D. (2026). _Códigos postales de España_ (version 1.0.0) [Dataset]. Zenodo. doi:10.5281/zenodo.23698418. * Sánchez, J. I. (2020, November 13). _Así hice el mapa de los códigos postales de España con SIG y datos abiertos_. NoSoloSIG. Article.

dieghernan.github.io

MITECO data and firefly cartography with R

Large forest fires in Spain

**GIFs** provides a dataset and an infographic of large forest fires in Spain, compiled from the statistics of the Ministry for the Ecological Transition and the Demographic Challenge (MITECO). Here, GIF means _gran incendio forestal_ : a fire with at least 500 hectares of forest area burned. The project uses **R** to prepare the data and create a map inspired by Dominic Royé’s firefly cartography. ## Data and interpretation Records span February 27, 2010 to September 26, 2026. These dates mark the first and last records in the dataset; they do not represent complete annual coverage. The dataset is not a real-time fire monitoring service. The CSV contains municipality and province names, INE codes, dates and forest area burned in hectares. It combines final statistics for 2010–2021 with provisional reports for 2022–2026. Dates recorded as December 31, 2012 identify the year only, rather than a confirmed day of ignition. Map points use municipal reference locations from **mapSpain** , not exact fire locations or perimeters. Circle sizes aggregate forest area burned at each reference location. ## Downloads and reuse The project website provides the infographic, a CSV download and citation information. Consult its documented methodology for collection decisions, source limitations and validation. Machine-readable field descriptions are available in the Croissant metadata. Data reuse follows the MITECO legal notice, including attribution and preservation of the original conditions and metadata. The repository’s MIT license applies to its code and documentation. The project is independent and does not imply MITECO participation or endorsement. Cite the dataset using its Zenodo DOI.

dieghernan.github.io