Points Map Rendering

Static PNG generation of GeoJSON points using GD::GIS, YAML styles and OpenStreetMap basemaps.

Render Preview

Preview of the generated PNG map using different point rendering modes: image icons, numeric markers, and alphabetic markers.

# Create output directory
mkdir output

# Install dependency
gem install libgd-gis

# Run the script
ruby points.rb

Expected output:

✔ Generated: output/aerial.png
Rendered Points map
Generated with libgd-gis · Basemap © OpenStreetMap
Rendered Points map
Generated with libgd-gis · Basemap © OpenStreetMap
Rendered Points map
Generated with libgd-gis · Basemap © OpenStreetMap

Style definition (solarized.yml)

global:
  label:
    color: [35, 35, 35, 20]

points:
  color: [0, 0, 127, 0]
  font_color: [250, 250, 250]
  font: /usr/share/fonts/truetype/lato/Lato-Regular.ttf
  size: 10
  icon: icon.png
  # icon can also be: numeric | alphabetic

Ruby script (points.rb)

require "gd/gis"
require_relative "fonts"

OUTPUT = "output/aerial.png"
GEOJSON = "data/aerial.geojson"

bbox = GD::GIS::Geometry.bbox_for_image(
  GEOJSON,
  zoom: 13,
  width: 800,
  height: 600,
  padding_px: 100
)

map = GD::GIS::Map.new(
  bbox: bbox,
  zoom: 15,
  width: 800,
  height: 600,
  basemap: :osm
)

map.style = GD::GIS::Style.load("solarized")
map.add_geojson(GEOJSON)

map.render
map.save(OUTPUT)

puts "✔ Generated: #{OUTPUT}"