libgd-gis is a A native map rendering engine for Ruby built on libgd.
It allows developers to generate maps, tiles, and heatmaps directly from GeoJSON using the libgd raster engine — without external services.
libgd-gis is useful for:
- Generating static maps for Rails applications
- Rendering GeoJSON data to PNG images
- Creating heatmaps and geographic visualizations
- Building internal dashboards with map outputs
- Self-hosted alternatives to static map APIs
map = GD::GIS::Map.new(
bbox: PARIS,
zoom: 13,
basemap: :carto_light)
map.add_geojson("countries.geojson")
map.add_point(lat: -34.6, lon: -58.4)
map.render
map.save("map.png")🆕 Update: Style is no longer mandatory. Maps now render out-of-the-box using a built-in default style.
- Web Mercator map and tile rendering (OSM, CARTO, ESRI, Stamen, etc.)
- CRS normalization (CRS84, EPSG:4326, EPSG:3857, Gauss–Krüger Argentina)
- Layered rendering pipeline
- YAML-based styling
- Rule-based semantic classification (ontology)
- Points, lines, and polygons support
- No heavy GIS dependencies
Add to your Gemfile:
gem "libgd-gis"Then run:
bundle installYou must also have GD available on your system.
require "gd/gis"
map = GD::GIS::Map.new(
bbox: [-58.45, -34.7, -58.35, -34.55],
zoom: 13,
basemap: :carto_light,
width: 1024,
height: 768
)map.style = GD::GIS::Style.load("default", from: "styles")map.add_geojson("data/roads.geojson")
map.add_geojson("data/water.geojson")map.render
map.save("map.png")require "gd/gis"
map = GD::GIS::Map.new(
bbox: PARIS,
zoom: 13,
basemap: :carto_light
)
map.style = GD::GIS::Style.load("default")
map.render# styles/default.yml
roads:
motorway:
stroke: [255, 255, 255]
stroke_width: 10
fill: [60, 60, 60]
fill_width: 6
primary:
stroke: [200, 200, 200]
stroke_width: 7
fill: [80, 80, 80]
fill_width: 4
street:
stroke: [120, 120, 120]
stroke_width: 1
rail:
stroke: [255, 255, 255]
stroke_width: 6
fill: [220, 50, 50]
fill_width: 4
center: [255, 255, 255]
center_width: 1
water:
fill: [120, 180, 255]
fill_width: 4
stroke: [80, 140, 220]
park:
fill: [40, 80, 40]
order:
- water
- park
- street
- primary
- motorway
- railThis design ensures predictable rendering and makes all visual decisions explicit and reproducible.
LibGD-GIS includes a global dataset of predefined geographic areas.
You can use them directly as the bbox parameter.
map = GD::GIS::Map.new(
bbox: :argentina,
zoom: 5,
width: 800,
height: 600,
basemap: :osm
)You can also use continents or regions:
bbox: :world
bbox: :europe
bbox: :south_america
bbox: :north_america
bbox: :asia
Supported input CRS:
- CRS84
- EPSG:4326
- EPSG:3857
- EPSG:22195 (Gauss–Krüger Argentina, zone 5)
All coordinates are normalized internally to CRS84 (lon, lat).
MIT



