class visigoth.map_layers.ruler.Ruler(label='', decimal_places=2, stroke='black', stroke_width=2, font_height=16, text_attributes={})

Construct a map layer to display a ruler

Keyword Arguments
  • label (str) – label for ruler

  • decimal_places (int) – the number of decimal places to display

  • stroke (str) – stroke colour for axis line

  • stroke_width (int) – width of axis line

  • font_height (int) – the font size in pixels

  • text_attributes (dict) – a dict containing SVG name/value pairs


Screenshot (Link to open SVG for interactive features):


Source Code (Link to Github):

import os.path
import sys
import argparse
import random

from visigoth import Diagram
from import Map
from visigoth.map_layers.wms  import WMS
from visigoth.map_layers.ruler  import Ruler
from visigoth.utils.mapping import Mapping
from import Box
from visigoth.common.text import Text

if __name__ == "__main__":

    parser = argparse.ArgumentParser()
    parser.add_argument("--outpath", help="path for output SVG", default="example.svg")
    args = parser.parse_args()

    d = Diagram(fill="white")

    bounds = ((166.509144322, -46.641235447),(178.517093541, -34.4506617165))

    m = Map(512,bounds,zoom_to=4)
    # m.addLayer(WMS(layers=["osm_3857"]))

    svg = d.draw()

    f = open(args.outpath, "wb")