DEV Community

Germán Alberto Gimenez Silva
Germán Alberto Gimenez Silva

Posted on • Originally published at rubystacknews.com on

🌍 Rendering Maps by Name: Symbolic Geographic Extents in Ruby

Working with maps usually means working with numbers — lots of numbers.

If you want to render a map of a country, region, or continent, you normally need to know its exact bounding box:

bbox = [-73.6, -55.1, -53.6, -21.7] # Argentina
Enter fullscreen mode Exit fullscreen mode

Not exactly readable. Not memorable. Not friendly.

What if you could just say:

bbox: :argentina
Enter fullscreen mode Exit fullscreen mode

With the latest update to libgd-gis , you can.


🧠 Named Geographic Extents

LibGD-GIS now includes a global dataset of predefined geographic areas.

Each area maps a human-readable name to a WGS84 bounding box.

Instead of coordinates, you use concepts.

  • :world
  • :europe
  • :asia
  • :north_america
  • :argentina
  • :japan
  • …and many more

🚀 Example: Render Argentina in Seconds

require "gd/gis"

map = GD::GIS::Map.new(
  bbox: :argentina,
  zoom: 5,
  width: 800,
  height: 600,
  basemap: :osm
)map.render
map.save("argentina.png")
Enter fullscreen mode Exit fullscreen mode

No coordinates. No GIS lookup. No guesswork.


🌎 Example: Entire World

map = GD::GIS::Map.new(
  bbox: :world,
  zoom: 2,
  width: 1000,
  height: 600,
  basemap: :osm
)map.render
map.save("world.png")
Enter fullscreen mode Exit fullscreen mode

Perfect for dashboards, reports, or quick visualizations.


🌏 Continents and Regions

Because extents include continents, you can generate regional maps just as easily.

regions = [:europe, :asia, :south_america]regions.each do |region|
  map = GD::GIS::Map.new(
    bbox: region,
    zoom: 3,
    width: 900,
    height: 600,
    basemap: :osm
  ) map.render
  map.save("#{region}.png")
end
Enter fullscreen mode Exit fullscreen mode

This is extremely useful for batch generation of visuals.


🔎 Under the Hood

You can also query the dataset directly:

GD::GIS::Extents.fetch(:argentina)
# => [min_lng, min_lat, max_lng, max_lat]GD::GIS::Extents.all
# => [:world, :europe, :asia, :argentina, ...]
Enter fullscreen mode Exit fullscreen mode

Coordinates use:

  • WGS84 (EPSG:4326)
  • Longitude/Latitude order
  • Approximate bounds for visualization


⭐ Why This Matters

Named extents turn raw geometry into meaningful geography.

Instead of thinking:

“What are the coordinates?”

You think:

“What place do I want?”

This makes code:

✔ More readable

✔ Easier to maintain

✔ Faster to prototype

✔ Ideal for automation

✔ Friendly for non-GIS developers


libgd-gis (Ruby GIS raster engine)

Render maps, GeoJSON, heatmaps, and tiles — built on libgd.

RubyGems → Install libgd-gisGitHub → Source & Docs

Gemfile:gem “libgd-gis”

Links: RubyGems · GitHub


🏁 Conclusion

Symbolic geographic extents bring a simple but powerful idea to server-side mapping:

Use names instead of numbers.

For many applications — dashboards, reporting, monitoring, education, or demos — this is exactly what you need.

And sometimes, the biggest usability improvements come from removing complexity, not adding features.

Top comments (0)