LibGD GIS
Germán Alberto Giménez Silva | Remote | 🟢 Open to work
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.
Use Cases
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
Example
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.
Features
- 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
Installation
Add to your Gemfile:
gem install libgd-gisThen run:
bundle installYou must also have GD available on your system.
Basic Usage
Create a map
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
)Load a style
map.style = GD::GIS::Style.load("default", from: "styles")Load GeoJSON
map.add_geojson("data/roads.geojson")
map.add_geojson("data/water.geojson")Render
map.render
map.save("map.png")Example:
require "gd/gis"
map = GD::GIS::Map.new(
bbox: PARIS,
zoom: 13,
basemap: :carto_light
)
map.style = GD::GIS::Style.load("default")
map.renderExample:
# 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.
Named geographic extents
LibGD-GIS includes a global dataset of predefined geographic areas.
You can use them directly as the bbox parameter.
Example
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
CRS Support
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).
License
MIT



