Skip to content

RenderSettings

RenderSettings

use qgis_render::RenderSettings;

The lightweight builder for a render. It answers “how big, which area, which CRS” and leaves everything else at a sensible default. Reach for MapSettings when you also need per-layer selection or filter overrides.

Construction

let settings = RenderSettings::new(1024, 768)
.extent(project.extent())
.crs(Crs::from_epsg(3857)?)
.dpi(96)
.background(Color::WHITE);
let image = project.render_to_image(settings)?;
image.save("map.png")?;

RenderSettings::new(width, height) takes the output size in pixels.

Builder methods

MethodDefaultDescription
.extent(Extent)project extentArea to render.
.crs(Crs)project CRSOutput CRS. Reprojection is automatic.
.dpi(u32)96Drives label sizes and symbol scaling.
.background(Color)Color::TRANSPARENTBackground fill.

Aspect ratio

The extent and the pixel size are independent: a non-matching ratio stretches the map. Compute one from the other when the output has to be undistorted.

let extent = project.extent();
let ratio = extent.width() / extent.height();
let (w, h) = (2048, (2048.0 / ratio) as u32);
let image = project.render_to_image(
RenderSettings::new(w, h).extent(extent)
)?;

Choosing a DPI

DPIUse
72–96Screen and web maps.
150Presentations and reports.
300Print.

DPI scales labels and marker symbols, so a 300 DPI render of the same extent is legible when printed rather than tiny.

See also

  • render — the render entry points and MapSettings
  • Crs — output coordinate systems
  • layout — print layouts, which carry their own scale
  • Rendering Projects — worked examples