Project

libgd-gis

0.0
The project is in a healthy, maintained state
A native GIS raster engine for Ruby built on libgd. Render maps, GeoJSON, heatmaps and tiles.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Runtime

~> 0.1.6, >= 0.1.6
 Project Readme

LibGD-GIS

Examples Examples Examples

A geospatial raster engine for Ruby.

libgd-gis allows Ruby to render real maps, GeoJSON layers, vector features, and geospatial tiles using a native raster backend powered by libgd.

It restores something Ruby lost over time: the ability to generate maps, tiles, and GIS-grade visualizations natively, without relying on external tools like QGIS, Mapnik, ImageMagick, or Mapbox.

Built on top of ruby-libgd, this project turns Ruby into a map rendering engine, capable of producing spatial graphics, tiled maps, and geospatial outputs directly inside Ruby processes.

  • No external renderers.
  • No shelling out.
  • Just Ruby, raster, and GIS.

What is this?

libgd-gis is a geospatial rendering engine for Ruby built on top of ruby-libgd.

It allows you to:

  • Load GeoJSON, CSV, or any dataset with coordinates
  • Fetch real basemap tiles
  • Reproject WGS84 (lat/lon) into Web Mercator
  • Render points, icons, and layers onto a raster map
  • Generate PNG maps or map tiles

This is the same type of pipeline used by professional GIS systems — implemented in Ruby.


Installation

System dependency

libgd-gis depends on libgd, via ruby-libgd.

Install libgd first:

Ubuntu / Debian

sudo apt install libgd-dev

macOS

brew install gd

Ruby gems

gem install ruby-libgd
gem install libgd-gis

Quick Example

Render hydroelectric plants from a GeoJSON file:

require "json"
require "gd/gis"

# ---------------------------
# Bounding box mundial
# ---------------------------
AMERICA = [-170, -60, -30, 75]

# ---------------------------
# Crear mapa
# ---------------------------
map = GD::GIS::Map.new(
  bbox: AMERICA,
  zoom: 4,
  basemap: :carto_light
)

# Cargar datos
# ---------------------------
peaks = JSON.parse(File.read("picks.json"))

# ---------------------------
# Agregar capa de puntos
# ---------------------------
map.add_points(
  peaks,
  lon: ->(p) { p["longitude"] },
  lat: ->(p) { p["latitude"] },
  icon: "peak.png",
  label: ->(p) { p["name"] },
  font: "./fonts/DejaVuSans.ttf",
  size: 10,
  color: [0,0,0]
)

# ---------------------------
# Renderizar y guardar
# ---------------------------
map.render
map.save("output/america.png")

puts "Saved output/america.png"

Features

  • Real basemap tiles
  • WGS84 → Web Mercator projection
  • GeoJSON point rendering
  • CSV / JSON support
  • Icon-based symbol layers
  • Automatic bounding box fitting
  • Raster output (PNG)

License

MIT


Author

Germán Silva https://github.com/ggerman https://rubystacknews.com