Skip to content

Add symbol size/shape translator for tmap and mapgl #16

@NewGraphEnvironment

Description

@NewGraphEnvironment

Problem

The gq registry stores point mark properties as radius (in QGIS mm units, e.g. 2.0, 2.4, 3.0), but gq_tmap_style() only returns fill and size for points — and the size value from the registry doesn't translate well to tmap's size units. A registry radius of 2.4 becomes nearly invisible in tmap at default figure dimensions.

This means every map manually guesses tmap size values through trial and error. The same problem will exist for mapgl circle radius.

Proposed Solution

Add a symbol size translator that converts registry mark radius to target-appropriate sizes:

# Returns size calibrated for tmap
gq_tmap_style(reg$layers$fiss_obstacles)
# $fill = "black", $size = 0.5  (not 2.0)

# Or a standalone converter
gq_symbol_size(radius = 2.4, target = "tmap")  # returns 0.5
gq_symbol_size(radius = 2.4, target = "mapgl")  # returns 6

The conversion factor depends on the target renderer:

  • tmap v4: sizes in proportional units (0-1 range typical for maps)
  • mapgl: circle-radius in pixels
  • QGIS: mm (already in registry)

Could also handle shape mapping — QGIS shape names (square, triangle, circle) to R pch codes or mapgl equivalents.

Discovered while building the fresh subbasin vignette — falls (registry radius 2.0) and fish observations (radius 2.4) were invisible at their registry sizes in tmap.

Relates to #9

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions