PitchHut logo
Effortlessly create maps and visualizations in Ruby without external services.
Pitch

libgd-gis offers a powerful native GIS and map-rendering engine for Ruby, leveraging the capabilities of ruby-libgd. It simplifies the process of generating map images and geospatial visuals directly from latitude/longitude or GeoJSON data, eliminating dependence on external map services and image pipelines.

Description

libgd-gis is a native GIS and map-rendering engine for Ruby that leverages the powerful libgd library. This tool enables developers to generate map images, tiles, and geospatial visualizations directly from latitude and longitude data or GeoJSON files, all without the need for external map servers or image processing pipelines.

Key Features

  • Web Mercator Rendering: Supports various basemaps (OSM, CARTO, ESRI, Stamen, etc.) for versatile map design.
  • Coordinate Reference System (CRS) Normalization: Handles multiple CRS formats, including CRS84, EPSG:4326, EPSG:3857, and Gauss–Krüger for Argentina.
  • Layered Rendering Pipeline: Offers a structured approach to map rendering, useful for managing complex visualizations.
  • YAML-based Styling: Utilize customizable styling options that can be adjusted to fit specific visualization needs.
  • Semantic Classification: Features rule-based classification for points, lines, and polygons, ensuring meaningful representation of data.
  • Lightweight Dependency: Built to operate with minimal GIS dependencies.

Use Cases

  • Creating static maps suitable for Ruby on Rails applications.
  • Rendering GeoJSON data into PNG images for robust data visualization.
  • Generating heatmaps and other geographic visualizations effortlessly.
  • Developing internal dashboards that incorporate map outputs.
  • Providing self-hosted alternatives to traditional static map APIs.

Example Usage

To create a map using libgd-gis, the following Ruby code illustrates the basic setup:

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.add_geojson("data/roads.geojson")
map.add_geojson("data/water.geojson")
map.render
map.save("map.png")

This code initializes a map centered on a specified bounding box, adds layers from GeoJSON data, and saves the rendered output.

Geographic Extents

libgd-gis comes with a wide range of predefined geographic areas that can be utilized directly within various functionalities. For example:

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

Conclusion

libgd-gis is ideal for developers seeking a straightforward solution for integrating mapping capabilities within Ruby applications. With its robust feature set and ease of use, this library presents a powerful option for generating custom maps and geospatial visualizations.

0 comments

No comments yet.

Sign in to be the first to comment.