homesolutionsContent hubblogcontact
R

Visualizing Spatial Data: Delaunay Triangulations and Voronoi Diagrams with the deldir Package in R

Ronaldo Menezes
Aug 1, 2024
HomeBlogR
Post
D

elaunay Triangulations / Voronoi Diagram

The deldir package in R is a powerful tool for performing Delaunay triangulations and generating Voronoi diagrams. It is useful for spatial analysis and geometric modeling. In this article, I will provide an overview of its functionalities, how to use them, and an explanation of the concepts of Delaunay triangulation and Voronoi diagrams.

Fundamental Concepts

Voronoi Diagram:
A Voronoi diagram divides space into regions, where each region corresponds to a point in a set of points. All points within a region are closer to the corresponding point than to any other point.

Delaunay Triangulation:
Delaunay triangulation is a triangulation of a set of points that maximizes the minimum angle of all the triangle's angles, avoiding "thin" triangles. Each triangle has a circumscribed circle that does not contain other points in the set.

Using the deldir Package

Installation and Loading

First, install and load the deldir package:

‍


install.packages("deldir")
library(deldir)
  

‍

Main Functions

deldir

The primary function to perform Delaunay triangulation and create a Voronoi diagram:


voronoi_data <- deldir(x, y)
  

Where x and y are vectors containing the coordinates of the points.

tile.list

Extract Voronoi cells from the deldir object:


tiles <- tile.list(voronoi_data)
  

plot.deldir

Plot the Voronoi diagram and/or the Delaunay triangulation:


plot(voronoi_data)
  

‍

‍

Converting to a SpatialLinesDataFrame

Converting to SpatialLinesDataFrame:

  • The tile.list function is used to convert the voronoi_data object into a list of polygons, where each polygon represents a Voronoi cell.
  • A voronoi_lines list is created to store the polygon lines.

Creating the SpatialLinesDataFrame Object:

  • A loop iterates over each polygon in the voronoi_tiles list.
  • For each polygon, the coordinates are extracted and added to the voronoi_lines list as a Lines object.
  • All lines are then converted into a SpatialLines object and finally into a SpatialLinesDataFrame, with line IDs assigned automatically.

Creating the Leaflet Mapa


library(leaflet)

map <- leaflet() %>%
 addTiles() %>%
 addProviderTiles(providers$Esri.WorldImagery) %>%
 addCircles(lng = ignition_points$LONGITUDE, lat = ignition_points$LATITUDE, radius = 500, color = "red", fill = TRUE, fillOpacity = 0) %>%
 addPolylines(data = voronoi_spdf, color = "yellow", weight = 1)

map
  

‍

Explanation

  • Converting to SpatialLinesDataFrame:
    • tile.list converts the voronoi_data object into a list of polygons, with each polygon representing a Voronoi cell.
    • A loop iterates over each polygon in the list, extracting the coordinates and adding them to the voronoi_lines list as a Lines object.
    • These lines are then converted into a SpatialLines object and finally into a SpatialLinesDataFrame, with IDs assigned automatically.
  • Creating the Leaflet Map:
    • A leaflet map is created using addTiles() to add a default set of base tiles.
    • Satellite imagery tiles from Esri are added with addProviderTiles(providers$Esri.WorldImagery).
    • Ignition points are added to the map as red circles using their longitude and latitude coordinates.
    • Voronoi diagram lines are added as yellow polylines.

Displaying the Map

The map is displayed using the map object, providing a clear visualization of the Voronoi diagram overlaid on a satellite map.

Tags:
r
Tutoriais
about the author
Ronaldo Menezes

Ronaldo brings decades of expertise to the field of geotechnology. Now, he's sharing his vast knowledge through exclusive courses and in-depth e-books. Get ready to master spatial and statistical analysis techniques, and raise your professional level.

see all articles
featured content
Climate Changes
The Thermohaline Circulation and Climate Change
R
Five of the best software for working with geographic data, excluding GDAL, which is often used by many of them
Geographic Images
The five best places to find geographic data, with the rationale for each choice
Technology
The ten best groups to learn about geoprocessing, with the rationale for each choice
Geographic Images
Five of the best YouTube channels for learning and collecting geographic data, with a rationale for each choice
Geotechnologies
Geotechnology, Agribusiness and climate change
newsletter

Sign up for our Newsletter to receive content and tips on Geotechnology and R. 👇

Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.

Content you might also like

Climate Changes
Spring Flooding in Kazakhstan
For the second year in a row, northern Kazakhstan experienced significant flooding caused by rapid snowmelt combined with intense spring rains. In 2025, this natural phenomenon once again inundated riverside communities, displacing hundreds of residents and impacting livelihoods along the Esil River and other waterways.
May 29, 2025
Ronaldo Menezes
Geotechnologies
Unlocking Geospatial Power: Understanding Algorithm Providers in QGIS
QGIS has become a cornerstone of open-source geospatial analysis, offering a powerful and flexible environment for spatial data processing. At the heart of its analytical capabilities lies a hidden gem that many users overlook: Algorithm Providers.These providers serve as the engines behind QGIS’s geoprocessing tools, enabling users to perform everything from simple vector operations to advanced raster modeling—all from a single, unified interface. Understanding how these algorithm providers work—and how to access them—can drastically improve your workflow and unlock the full potential of QGIS.
May 9, 2025
Ronaldo Menezes
Geotechnologies
Floating Solar Power: A Smart Solution for India’s Renewable Energy Future
India is rapidly advancing its renewable energy landscape, and one innovation is standing out as a true game-changer: floating solar power. By installing photovoltaic (PV) panels on reservoirs and other water bodies, India is taking a smart and sustainable step towards meeting its growing energy demands without exacerbating land-use conflicts.
Apr 28, 2025
Ronaldo Menezes
Geographic Images
Copernicus Emergency Management Service Responds to the 7.7 Magnitude Earthquake in Myanmar
On March 28, 2025, a catastrophic earthquake measuring 7.7 on the Richter scale struck Myanmar, causing widespread devastation. The epicenter was located near Mandalay, Myanmar’s second-largest city, and the tremors were felt across the region. This powerful earthquake has resulted in significant human and infrastructural losses, with over 1,700 confirmed dead and more than 3,400 injured.
Apr 2, 2025
Ronaldo Menezes
Geographic Images
Revolutionizing Climate Science: Generating 3D Cloud Maps Using AI and Satellite Data
In a groundbreaking development for climate science, an international team of scientists has harnessed the power of artificial intelligence (AI) to create 3D profiles of clouds from satellite data. This innovative approach promises to provide new insights into cloud structures and their role in climate systems—something eagerly anticipated by researchers awaiting data from the EarthCARE mission.
Mar 27, 2025
Ronaldo Menezes
Geographic Images
Exploring Halong Bay: A Stunning Satellite View of Vietnam’s UNESCO World Heritage Site
Halong Bay, located in northeast Vietnam, is a remarkable landscape featured in this Copernicus Sentinel-2 satellite image. The image captures the bay's striking rocky formations rising from the clear blue waters, offering a breathtaking view of one of the most iconic natural wonders in Southeast Asia.
Mar 24, 2025
Ronaldo Menezes
see all
Social media

Follow us on Instagram

@rmgeoeasy
contact

Contact us

Talk to us on WhatsApp

+351 919 428 158 >

Send us an E-mail

geoeasy0@gmail.com >

Follow our content

Go to Instagram >

homesolutionscontact
talk to us
© Copyright 2024 | Geoeasy Geotechnology
Carefully developed by Digital Bloom