Build a ggsql query string that draws a choropleth from
a registered countryatlas source – the same idea as world_map(), but the
map is rendered in the database (DuckDB) and returned as a web-ready
Vega-Lite widget, so the geometry never has to come back into R. Pure string
builder with no dependencies; pair it with as_ggsql_source() +
ggsql::ggsql_execute(), or drop the string into a {ggsql} chunk.
Usage
world_query(
fill,
source = "countryatlas_world",
projection = "equal_earth",
palette = "viridis",
transform = NULL,
title = NULL,
draw = "spatial"
)Arguments
- fill
The fill column (unquoted or a string).
- source
The table/source name registered with ggsql (default
"countryatlas_world").- projection
A projection ggsql's
PROJECT TOunderstands (e.g."equal_earth","orthographic"), orNULLto omit the clause.- palette
A scale ggsql's
SCALE ... TOunderstands (default"viridis"), orNULLto omit.- transform
Optional scale transform for
SCALE ... VIA(e.g."log10").- title
Optional plot title (
LABEL title => ...).- draw
The spatial layer (default
"spatial").
Examples
world_query(gdp_per_capita, projection = "equal_earth",
palette = "magma", transform = "log10",
title = "GDP per capita")
#> VISUALISE gdp_per_capita AS fill
#> FROM countryatlas_world
#> DRAW spatial
#> PROJECT TO equal_earth
#> SCALE fill TO magma VIA log10
#> LABEL title => 'GDP per capita'
